View Full Version : reloading apache
damieno
09-28-2008, 11:05 AM
Hi,
I am using RoR on a shared IP using FASTCGI (fcgid-script). I made some database.yml changes and needed to bounce my app (http://wiki.rubyonrails.org/rails/pages/database.yml).
Normally, I would send HUP to my apache process, this is what I did and it worked. I just wondered if there is a way to send HUP to apache through the cPanel, I only see the ability to send a "kill process", no HUP. Perhaps I am blind :o, but I didn't see it in cPanel. It would be a nice feature for such situations.
Thanks,
Damien
Early Out
09-29-2008, 06:55 AM
You're on shared hosting. You can't restart Apache - doing so would bounce the other 400 accounts on your server!
badreligion
10-14-2008, 11:41 AM
Why can't you just kill your fcgi process? There is no need to reload Apache.
You would need SSH access and it sounds like you could a bit dangerous with that ;)
ps auxww | grep -E "^<your username>(.*)fcgi" | awk '{print $2}'
If you properly substituted your username in the <your username>, that will give you the PID of your fcgi processes. Then with those do
kill -USR1 <PID>
EXAMPLE:
[fighterg@box474 www]$ ps auxww | grep -E "^fighterg(.*)fcgi" | awk '{print $2}'
12899
29074
[fighterg@box474 www]$ ps auxww | grep -E "^fighterg(.*)fcgi"
[fighterg@box474 www]$ kill -USR1 12899 29074
It might be a good idea to make sure you are getting the right information first like this:
[fighterg@box474 www]$ ps auxww | grep -E "^fighterg(.*)fcgi"
fighterg 13334 0.0 0.0 51172 772 pts/1 S+ 11:40 0:00 grep -E ^fighterg(.*)fcgi
fighterg 29074 0.2 0.5 81000 47764 ? S 11:29 0:01 /usr/bin/ruby dispatch.fcgi
You are looking for the numbers that I have bolded, you want to make sure your username is the first field (the owner of the process) and that the last field is the fcgi daemon. So you won't do something stupid like kill off your SSH process :D.
I actually wrote a shell script that just shoves the output of the command that uses 'awk' above and you can just do something like this:
[fighterg@box474 www]$ cat ~/bin/killfcgi.sh
#!/bin/bash
pids=`ps auxww | grep -E "^<your user name>(.*)fcgi$" | grep -v 'grep' | awk '{print $2}'`
printf "Sending HUP signal to all fcgi processes: "
if ( kill -USR1 $pids &>/dev/null )
then
printf "OK\n"
exit 0
else
printf "ERROR\n"
fi
exit 1
Hope this helps someone.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.