Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. Capistrano::Configuration.instance.load do
  2. before 'deploy:stop', 'mailman:stop'
  3. after 'deploy:start', 'mailman:start'
  4. before 'deploy:restart', 'mailman:restart'
  5.  
  6. _cset(:mailman_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec mailman" }
  7. _cset(:mailman_config) { "#{current_path}/config/mailman.rb" }
  8. _cset(:mailman_role) { :app }
  9. _cset(:mailman_pid) { "#{current_path}/tmp/pids/mailman.pid" }
  10.  
  11. namespace :mailman do
  12. desc 'Stop mailman'
  13. task :stop, roles: lambda { fetch(:mailman_role) }, on_no_matching_servers: :continue do
  14. run "if [ -d #{current_path} ] && [ -f #{mailman_pid} ] && kill -0 `cat #{mailman_pid}` > /dev/null 2>&1; then cd #{current_path} && rm #{mailman_pid} ; else echo 'Mailman is not running'; fi"
  15. end
  16.  
  17. desc 'Start mailman'
  18. task :start do
  19. run "cd #{current_path} ; nohup #{fetch(:mailman_cmd)} -c #{fetch(:mailman_config)} -p #{fetch(:mailman_pid)} -e #{fetch(:rails_env, 'production')} >> #{current_path}/log/mailman.log 2>&1 &", pty: false
  20. end
  21.  
  22. desc 'Restart mailman'
  23. task :restart do
  24. stop
  25. start
  26. end
  27. end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement