Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

how can i restart spawn-fcgi on nginx server?

share|improve this question
add comment

5 Answers

Run it with option -P to store the PID in some temp file. For example:

/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -P /var/run/fcgi.pid 

Then you can kill it by this pid:

kill -9 `cat /var/run/fcgi.pid`
share|improve this answer
    
And make sure that PID file is writable by spawned process (if you're using -u/-g options) or it will be empty –  sendmoreinfo Aug 12 '12 at 13:22
add comment

Try this: https://github.com/szaydel/Rigel-Major/blob/master/shell-scripts/fastcgi-php

This should be what you are looking for.

share|improve this answer
add comment

How was the process for spawn-fcgi started, was it by a command line (manually) or using a rc-script. In either case you can kill the process by first finding the PID

Use the command ps aux | grep spawn-fcgi to locate the process and the command kill -9 PID

I recommend slashdot's recommendation of using the rc-script to start and end your spawn-fcgi process.

share|improve this answer
add comment

Update: This answer randomly failed on me (I'm not sure why) but I'm leaving this here because it might help someone.

killall -9 -w php-cgi

The "-w" waits. Because if you try to (re)start spawn-fcgi too soon (without a delay) spawn-fcgi always gave me error, something like "...already in use." (I don't remember the exact error, sorry.) However, "-w" doesn't work 100% of the time if you plan to put this in cron. After months of random php failures I decided to switch to php-fpm, which has its own unique problems--proceed with caution.

share|improve this answer
add comment

I actually prefer to do this kind of process management by using supervisor: http://supervisord.org/

Supervisor will "hang on to your processes": it will restart as necessary, manage the stdout/stderr logging and give you an explicit command for managing the processes without having to mess with PID files etc.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.