ruby - Clockwork recipe for Capistrano 3 -


<>

I'm trying to write a Clockwork recipe for Capistrano 3. After having a look at I came up with this:

  Namespace: Load Functions: The default sets are: clockwork_default_hooks, - & gt; {True} set: clock work_pid, - & gt; {'Tmp / pids / clockwork.pid'} Set: clockwork_log, - & gt; {"# {Current_path} /log/clockwork.log"} Set: clockwork_roles, - & gt; {: AP} Set: clockwork_config, - & gt; { "Clockkrb"} end end name before deploying: Location start ,: ': add_default_hooks do Clockwork "that get called check_clockwork_hooks (: clockwork_default_hooks) end end namespace: Clockwork def that bring clockwork_pid_full_path (: Clockwork_pid) after launching: .start_with (? '/') ("Clockwork_pid") and "# {current_path} / # {bring (clockwork_pid)}" end end:, after: 'stop clock': after 'Deploy updated' add_default_hooks' Deployment: brought back ',' Clockwork: stop 'after' deploy: Publish ',' Wish the clock: Start 'End Details' Clock Closure Cry 'task: Stop receiving light (: clockwork_roles) if the "test" within current_path [-f # {clockwork_pid_full_path}] "Execute" -int $ (cat # {clockwork_pid_full_path}) Kill 2 & gt; / Dev / null "and finally describe the end-end end of the 'start clockwork' work" echo 'clock was not running' ': bring the roles on (start: clockwork_roles) within the current (do: Acting on the 'production' RAILS_ENV) execute "export RAILS_ENV = $ RAILS_ENV" to: GT: {bring (clockwork_config)} and; & gt ;: what to bundle with _path RAILS_ENV ,: executive, clockwork, "# # {Fetch (: clockwork_log)} 2> & amp; 1 & amp; Amp; End and Excess; Ps -eo pid, command | Grep Clockwork | Grep -v grep | Awk '{print $ 1}' & gt; # {Clockwork_pid_full_path} "End End End" Restart Clock Task 'Start: Start Restart' Clock Clock: Stop 'Invoke' Clock Wish: Start 'End Ending'  

However, Clock: If I remove the 2 & gt; and amp; 1 & amp; part, then only the work begins . If I try to start the process in the background, then nothing happens.

What's wrong with me

This is where I ended up with whom I found.

  namespace: wish the clock "clock timer stop" work: stop roles (app) with the in Rilijh_pth rails_env: fetch (: rails_env) execute: Bundle,: Exec, : Clockworkd, "-c clock.rb --pid-dir = # {cw_pid_dir} --log-dir = # {cw_log_dir} - stop block" end and end "and" clockwork status "function: make on position roles ( : App) release_path with rails_env T: fetch (: ra Ils_env) Execute: Bundle ,: exec ,: clockworkd, "-c clock.rb --pid-dir = # {cw_pid_dir} --log-dir = # {cw_log_dir} --log situation" End end end end details "Start the clock" Task: Begin on roles (: app) within release_path with rails_env: Fetch (fetch: rails_env): bundle, exec: clockworkd, "-c Clock.rb - pid-dir = # {cw_pid_dir} --log-dir = # {cw_log_dir} --log start "end-end end desc" restart clockwork "work: do the role of restart (: Applications) within release_path Working with RAILS_ENV to: comply bring (: RAILS_ENV): Bundle ,: executive ,: clockworkd, "-c clock.rb --pid-dir = # {cw_pid_dir} --log-dir = # {cw_log_dir} --log restart "end end end end def cw_log_dir" # {shared_path} / log "and Diif cw_pid_dir" # {shared_path} / tmp / pids "end Diarf rails_env fetch (: rails_env, false)? "RAILS_ENV = # {fetch (: rails_env)}": '' End End  

Comments