我尝试使用自己的厨师独奏来启动nginx,但不断收到以下错误。
* service[nginx] action start
================================================================================
Error executing action `start` on resource 'service[nginx]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service nginx start ----
STDOUT: Starting nginx: [FAILED]
STDERR: nginx: [emerg] open() "/home/deploy/apps/...-api/shared/log/nginx.access.log" failed (2: No such file or directory)
---- End output of /sbin/service nginx start ----
Ran /sbin/service nginx start returned 1
Resource Declaration:
---------------------
# In /root/chef-solo/cookbooks-3/.../recipes/nginx.rb
60: service 'nginx' do
61: action [:enable, :start]
62: end
Compiled Resource:
------------------
# Declared in /root/chef-solo/cookbooks-3/.../recipes/nginx.rb:60:in `from_file'
service("nginx") do
action [:enable, :start]
supports {:restart=>nil, :reload=>nil, :status=>nil}
retries 0
retry_delay 2
default_guard_interpreter :default
service_name "nginx"
enabled true
pattern "nginx"
declared_type :service
cookbook_name :...
recipe_name "nginx"
end
Running handlers:
[2016-01-22T18:28:41+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-01-22T18:28:41+00:00] ERROR: Exception handlers complete
Chef Client failed. 11 resources updated in 25 seconds
[2016-01-22T18:28:41+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-01-22T18:28:41+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-01-22T18:28:41+00:00] ERROR: service[nginx] (...::nginx line 60) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service nginx start ----
STDOUT: Starting nginx: [FAILED]
STDERR: nginx: [emerg] open() "/home/deploy/apps/...-api/shared/log/nginx.access.log" failed (2: No such file or directory)
---- End output of /sbin/service nginx start ----
Ran /sbin/service nginx start returned 1
[2016-01-22T18:28:41+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.
include_recipe 'yum'
yum_repository 'nginx' do
baseurl 'http://nginx.org/packages/centos/6/$basearch/'
gpgcheck false
enabled true
action :create
end
yum_package 'nginx' do
options '--enablerepo=nginx'
action :install
end
# remove default nginx config
# default_path = '/etc/nginx/sites-enabled/default'
# execute "rm -f #{default_path}" do
# only_if { File.exist?(default_path) }
# end
directory '/etc/nginx/sites-available' do
owner 'deploy'
group 'deploy'
mode '0755'
recursive true
action :create
end
directory '/home/deploy/apps/...-api/current/public' do
owner 'deploy'
group 'deploy'
mode '0755'
recursive true
action :create
end
cookbook_file '/etc/nginx/sites-available/default' do
source 'nginx'
owner 'deploy'
group 'deploy'
mode '0755'
action :create
end
directory '/etc/nginx/sites-enabled' do
group 'deploy'
mode '0755'
owner 'deploy'
end
# set custom nginx config
cookbook_file '/etc/nginx/nginx.conf' do
source 'nginx-base'
owner 'deploy'
group 'wheel'
mode '0755'
action :create
end
service 'nginx' do
action [:enable, :start]
end
答案 0 :(得分:2)
正如输出所示,以下nginx
服务无法启动:
STDOUT: Starting nginx: [FAILED]
STDERR: nginx: [emerg] open() "/home/deploy/apps/...-api/shared/log/nginx.access.log" failed (2: No such file or directory)
确保目录/home/deploy/apps/...-api/shared/log/
存在且可写入Nginx。