
编辑:
我们最终做的有点不同……
码:
无法真正发布真实代码,但它是这样的:
在deploy / before_migrate.rb中:
[:schedule].each do |config_name| Chef::Log.info("Processing config for #{config_name}") begin template "#{release_path}/config/#{config_name}.rb" do |_config_file| variables( config_name => node[:deploy][:APP_name][:config_files][config_name] ) local true source "#{release_path}/config/#{config_name}.rb.erb" end rescue => e Chef::Log.error e raise "Error processing config for #{config_name}: #{e}" endend 在deploy / after_restart.rb中:
execute 'start whenever' do cwd release_path user node[:deploy][:APP_name][:user] || 'deploy' command 'bundle exec whenever -i APP_name'end
在config / schedule.rb.erb中:
<% schedule = @schedule || {} %>set :job_template,"bash -l -c 'export PATH=/usr/local/bin:${PATH} && :job'"job_type :runner,'cd :path && bundle exec rails runner -e :environment ":task" :output'job_type :five_runner,'cd :path && timeout 300 bundle exec rails runner -e :environment ":task" :output'set :output,'log/five_minute_job.log' every 5.minutes,at: <%= schedule[:five_minute_job_minute] || 0 %> do five_runner 'Model.method'end解决方法 我们在我们的仓库中有一本随时可以使用的食谱,欢迎您在这里使用: https://github.com/freerunningtech/frt-opsworks-cookbooks.我假设您熟悉在您的opsworks堆栈中添加自定义烹饪书. 我们通常在它自己的层上运行它,它还包括应用程序部署所需的rails cookbook(而不是app服务器):
>配置:rails :: configure
>部署:deploy :: rails
>取消部署:deploy :: rails-undeploy
但是,我们通常也会将此实例部署为应用程序服务器,这意味着我们最终还会从我们正在使用的框中提供请求.
有一个“问题”,因为你必须在schedule.rb顶部的env中设置你的路径,如下所示:
env :PATH,ENV['PATH']总结
以上是内存溢出为你收集整理的ruby-on-rails – 每当ws上的宝石都选择全部内容,希望文章能够帮你解决ruby-on-rails – 每当ws上的宝石都选择所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)