gpt4 book ai didi

tomcat - 用 Chef 部署war文件后如何重启tomcat?

转载 作者:行者123 更新时间:2023-11-28 21:56:22 24 4
gpt4 key购买 nike

我有自己的 Recipe ,它从 AWS S3 存储桶下载文件并尝试重启 tomcat 服务。

我正在使用来自 https://github.com/opscode-cookbooks/tomcat

的“官方”Tomcat 配方
FILE: myapp/recipes/default.rb

include_recipe 's3_file'
include_recipe 'tomcat::default'

s3_file "/var/lib/tomcat6/webapps/ROOT.war" do
remote_path node['myapp']['packages_s3_bucket_path'] + 'myapp.war'
bucket node['myapp']['packages_s3_bucket']
aws_access_key_id node['myapp']['packages_s3_bucket_aws_access_key']
aws_secret_access_key node['myapp']['packages_s3_bucket_aws_secret_key']
notifies :restart, "service[tomcat]", :immediately
end

问题是编译时没有找到service[tomcat](myapp的metadata.rb中也引用了tomcat)

Compiling Cookbooks...
[2015-01-14T00:56:14+00:00] WARN: Using java::default instead is recommended.
Converging 112 resources
[2015-01-14T00:56:15+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-01-14T00:56:15+00:00] ERROR: Running exception handlers
[2015-01-14T00:56:15+00:00] ERROR: Exception handlers complete
[2015-01-14T00:56:15+00:00] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2015-01-14T00:56:15+00:00] ERROR: resource s3_file[/var/lib/tomcat6/webapps/ROOT.war] is configured to notify resource service[tomcat] with action restart, but service[tomcat] cannot be found in the resource collection. s3_file[/var/lib/tomcat6/webapps/ROOT.war] is defined in /var/cache/chef/cookbooks/uaa/recipes/default.rb:69:in `from_file'

[2015-01-14T00:56:15+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

有什么想法吗?谢谢

最佳答案

假设您正在使用默认设置中的基础实例,那应该是 service[tomcat6]。服务资源为defined inside the LWRP .这只有效,因为提供不 use_inline_resources,所以在未来的某个时候,这可能不再有效。

编辑:

我在下面提到的 hack。

ruby_block 'restart tomcat' do
action :nothing
block do
resources('service[tomcat6]').run_action(:restart)
end
end

或类似的东西。通知 ruby​​ block ,它会查找真正的资源并重新启动它。

关于tomcat - 用 Chef 部署war文件后如何重启tomcat?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27934224/

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