Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Capistrano::Configuration.instance.load do
- before 'deploy:stop', 'mailman:stop'
- after 'deploy:start', 'mailman:start'
- before 'deploy:restart', 'mailman:restart'
- _cset(:mailman_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec mailman" }
- _cset(:mailman_config) { "#{current_path}/config/mailman.rb" }
- _cset(:mailman_role) { :app }
- _cset(:mailman_pid) { "#{current_path}/tmp/pids/mailman.pid" }
- namespace :mailman do
- desc 'Stop mailman'
- task :stop, roles: lambda { fetch(:mailman_role) }, on_no_matching_servers: :continue do
- 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"
- end
- desc 'Start mailman'
- task :start do
- 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
- end
- desc 'Restart mailman'
- task :restart do
- stop
- start
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement