I'm running Nginx, FCGI, and Request Tracker on a Debian Jessie server. Request Tracker is served by Nginx, but FCGI sits between them. The important thing is that the FCGI server sometimes fails, resulting in users of RT seeing a 502 error. The fix is simple enough, but only because I've done it countless times in the last month or so. If I'm not around and someone else has to restart the FCGI server, they may have difficulty. Plus, stopping and restarting the server is annoying, but you need to do it to apply changes to RT.All that leads me to this: how can I best make the commands into an easier one? A script? A service, so it lives in /etc/init.d? Something else? I'm new to Debian, and Linux in general, so don't really know my options or how involved each might be. Here are the commands you have to issue:netstat -antp | grep LIST | grep 12345(This finds the FCGI server bound to port 12345, so I can get the PID. Say our PID is 8091.)kill 8091spawn-fcgi -u someUser -g someGroup -a 127.0.0.1 -p 12345 /opt/rt4/sbin/rt-server.fcgiOne important note here is that the netstat command could return nothing. If it does, the FCGI server has failed silently, so you skip the kill command and go right to the spawn-fcgi one. Otherwise, you keep the kill command in.Ideally, I'd love to have start/stop/restart options for something like /etc/init.d/rt-fcgi-server. I have no idea what to do for killing the process, though, because of the need to find the PID first. I've thought about using a .pid file, but I don't know how to tell spawn-fcgi to use one and what to do with such a file even if I had it. I don't even know if it would do what I want (keep the PID so I could avoid using the netstat command).I hope this is all making sense. I basically want to have one command, or something tied to /etc/init.d, to control the result of the spawn-fcgi command. I want non-root users, who know less about Linux than even I do, to be able to log in and run a single command, and I wouldn't mind a way to query the status of this process without using netstat, even if I don't have to get the PID to kill it. This way I can use something like Monit to auto-restart the server should it fail.
How to make this set of commands (to restart a server) easier?
debian;process