gpt4 book ai didi

deployment - 具有不相关默认符号链接(symbolic link)的 Chef 部署

转载 作者:行者123 更新时间:2023-12-02 23:36:48 26 4
gpt4 key购买 nike

我正在尝试使用 Chef 部署我的应用程序代码,该代码适用于一个节点,但在另一个节点上失败。我无法确定为什么它适用于一个节点而不适用于另一个节点(当它们具有完全相同的配置时),但我至少可以尝试调试失败节点上的问题。

  deploy_revision app_config['deploy_dir'] do
scm_provider Chef::Provider::Git
repo app_config['deploy_repo']
revision app_config['deploy_branch']
if secrets["deploy_key"]
git_ssh_wrapper "#{app_config['deploy_dir']}/git-ssh-wrapper" # For private Git repos
end
enable_submodules true
shallow_clone false
symlink_before_migrate({}) # Symlinks to add before running db migrations
purge_before_symlink [] # Directories to delete before adding symlinks
create_dirs_before_symlink [] # Directories to create before adding symlinks
# symlinks()
action :deploy
restart_command do
service "apache2" do action :restart; end
end
end

这是我部署代码的秘诀。请注意,我已尝试完全禁用符号链接(symbolic link),因为 Chef 总是将其自己的默认值塞进去。即使如此,我也会收到错误:

================================================================================
Error executing action `deploy` on resource 'deploy_revision[/var/www]'
================================================================================


Chef::Exceptions::FileNotFound
------------------------------
Cannot symlink /var/www/shared/config/database.yml to /var/www/releases/7404041cf8859a35de90ae72091bea1628391075/config/database.yml before migrate: No such file or directory - /var/www/shared/config/database.yml or /var/www/releases/7404041cf8859a35de90ae72091bea1628391075/config/database.yml

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/kapture/recipes/api.rb

68:
69: deploy_revision app_config['deploy_dir'] do
70: scm_provider Chef::Provider::Git
71: repo app_config['deploy_repo']
72: revision app_config['deploy_branch']
73: if secrets["deploy_key"]
74: git_ssh_wrapper "#{app_config['deploy_dir']}/git-ssh-wrapper" # For private Git repos
75: end
76: enable_submodules true

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/kapture/recipes/api.rb:69:in `from_file'

deploy_revision("/var/www") do
destination "/var/www/shared/cached-copy"
symlink_before_migrate {"config/database.yml"=>"config/database.yml"}
updated_by_last_action true
restart_command #<Proc:0x00007f40f366e5a0@/var/chef/cache/cookbooks/kapture/recipes/api.rb:82>
repository_cache "cached-copy"
retries 0
keep_releases 5
create_dirs_before_symlink ["tmp", "public", "config"]
updated true
provider Chef::Provider::Deploy::Revision
enable_submodules true
deploy_to "/var/www"
current_path "/var/www/current"
recipe_name "api"
revision "HEAD"
scm_provider Chef::Provider::Git
purge_before_symlink ["log", "tmp/pids", "public/system"]
git_ssh_wrapper "/var/www/git-ssh-wrapper"
remote "origin"
shared_path "/var/www/shared"
cookbook_name "kapture"
symlinks {"log"=>"log", "system"=>"public/system", "pids"=>"tmp/pids"}
action [:deploy]
repo "git@github.com:kapture/api.git"
retry_delay 2
end

[2012-09-24T15:42:07+00:00] ERROR: Running exception handlers
[2012-09-24T15:42:07+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2012-09-24T15:42:07+00:00] ERROR: Exception handlers complete
[2012-09-24T15:42:07+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2012-09-24T15:42:07+00:00] FATAL: Chef::Exceptions::FileNotFound: deploy_revision[/var/www] (kapture::api line 69) had an error: Chef::Exceptions::FileNotFound: Cannot symlink /var/www/shared/config/database.yml to /var/www/releases/7404041cf8859a35de90ae72091bea1628391075/config/database.yml before migrate: No such file or directory - /var/www/shared/config/database.yml or /var/www/releases/7404041cf8859a35de90ae72091bea1628391075/config/database.yml

在这里你可以看到它提到了database.ymltmp/system/pids文件夹,所有这些都是 Chef 喜欢设置的默认值(请参阅 related bug )

问题1

这些符号链接(symbolic link)的用途是什么以及我如何知道我是否需要任何符号链接(symbolic link)。我正在符号链接(symbolic link)什么类型的东西?我将使用迁移,因此如果它们对迁移有用,那么我将需要它们工作。

我已经多次阅读该文档,但它并没有解释这是简单的英语 - 至少我没有找到。

问题2

如果我不需要它们,如何完全禁用符号链接(symbolic link)?遵循该错误报告中的示例并没有帮助。

最佳答案

清除所有符号链接(symbolic link)属性。

deploy_revision("/var/www") do
# ...
symlink_before_migrate.clear
create_dirs_before_symlink.clear
purge_before_symlink.clear
symlinks.clear
end

关于deployment - 具有不相关默认符号链接(symbolic link)的 Chef 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12568767/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com