gpt4 book ai didi

nginx - 无法通过 Chef 启动 nginx 服务

转载 作者:行者123 更新时间:2023-12-04 19:34:29 28 4
gpt4 key购买 nike

我正在尝试使用 chef solo 启动 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.

nginx.rb
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

最佳答案

正如输出所说,以下 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 是可写的。

关于nginx - 无法通过 Chef 启动 nginx 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34953596/

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