#before "deploy", "deploy:stop_app"
#after "deploy", "deploy:start_app"
after "deploy", "deploy:restart_app"
namespace :deploy do
task :update_code, :roles => :web, :except => { :no_release => true } do
on_rollback { puts "DO NOT WANT TO ROLL BACK?" }
strategy.deploy!
finalize_update
end
task :stop_app, :roles => :web do
run "sudo /etc/init.d/xyz stop", :shell => :bash
end
task :start_app, :roles => :web do
run "sudo /etc/init.d/xyz start", :shell => :bash
end
task :restart_app, :roles => :web do
run "sudo /etc/init.d/xyz restart", :shell => :bash
end
end
case "$1" in
start)
printf "%-50s" "Starting $DAEMON_NAME..."
cd $DIR
[ -d $LOGPATH ] || mkdir $LOGPATH
[ -f $LOGFILE ] || su $DAEMON_USER -c 'touch $LOGFILE'
PID=`$PYTHON $DAEMON $DAEMON_OPTS > $LOGFILE 2>&1 & echo $!`
#echo "Saving PID" $PID " to " $PIDFILE
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status)
printf "%-50s" "Checking $DAEMON_NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $DAEMONNAME"
PID=`cat $PIDFILE`
cd $DIR
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac* executing `deploy:restart_app'
* executing multiple commands in parallel
-> "else" :: "sudo /etc/init.d/xyz restart"
-> "else" :: "sudo /etc/init.d/xyz restart"
-> "else" :: "sudo /etc/init.d/xyz restart"
-> "else" :: "sudo /etc/init.d/xyz restart"
servers: ["server1", "server2", "server3", "server4"]
[server1] executing command
[server2] executing command
[server3] executing command
[server4] executing command
** [out :: server1] Stopping
** [out :: server1] cat: /var/run/xyz.pid: No such file or directory
** [out :: server1] pidfile not found
** [out :: server1] Starting xyz...
** [out :: server2] Stopping
** [out :: server2] cat: /var/run/xyz.pid: No such file or directory
** [out :: server2] pidfile not found
** [out :: server2] Starting xyz...
** [out :: server2] Ok
** [out :: server1] Ok
** [out :: server3] Stopping
** [out :: server3] cat: /var/run/xyz.pid: No such file or directory
** [out :: server3] pidfile not found
** [out :: server4] Stopping
** [out :: server4] Ok
** [out :: server3] Starting xyz...
** [out :: server3] Ok
** [out :: server4] Starting xyz...
** [out :: server4] Ok
command finished in 659ms
Finished: SUCCESS
I can cat the file as the deploy user just fine.
task :stop_app, :roles => :web do
run "sudo /etc/init.d/xyz stop", :shell => :bash
end
task :debug_initd_stuff, :roles => :web do
run "sudo whoam"
run "sudo ls -l /etc/init.d"
run "sudo ls -l /var/run"
end
--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/56a2a2dd-fd26-4b14-a2da-0d7af37f8354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
** [out :: server1] Stopping
** [out :: server1] Ok
And the service also starts just fins
** [out :: server1] Starting xyz...
** [out :: server1] Ok
But on checking manually -- "service xyz status", i get this " Process dead but pidfile exist". I can stop and start the service just fine manually.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/d47d5020-1915-4194-be85-b72e157b0c23%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/bdf4409b-4f59-42f2-be66-2bb4f895dbfe%40googlegroups.com.
Deploying the ABC application via Capistrano
ffi-yajl/json_gem is deprecated, these monkeypatches will be dropped shortly
* executing `staging'
ffi-yajl/json_gem is deprecated, these monkeypatches will be dropped shortly
triggering start callbacks for `deploy'
* executing `multistage:ensure'
* executing `deploy'
triggering before callbacks for `deploy'
* executing `deploy:stop_app'
* executing multiple commands in parallel
servers: ["node1", "node2", "node3", "node4"]
connection failed for: node2 (Errno::ETIMEDOUT: Connection timed out - connect(2) for "node2" port 22)
Build step 'Execute shell' marked build as failure
Finished: FAILURE