Whenever a gem at aws opsworks

Does anyone have experience / success using any gem on aws opsworks? Have a good recipe? Can I put this recipe on a separate layer and associate one instance with this extra layer? Or is there a better way to do this? Thank!!!

EDIT:

We ended up with it a little differently ...

the code:

I can’t write real code, but like this:

in 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}"
  end
end

in 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

in 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
+3
source share
1 answer

, , : https://github.com/freerunningtech/frt-opsworks-cookbooks. , opsworks.

, , ( ):

  • : rails:: configure
  • : deploy:: rails when
  • Undeploy: deploy:: rails-undeploy

, , , , .

"gotcha", env .rb :

env :PATH, ENV['PATH']
+7

All Articles