LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Scripting with start-stop-daemon (https://www.linuxquestions.org/questions/linux-server-73/scripting-with-start-stop-daemon-926770/)

agentgates 01-31-2012 03:31 PM

Scripting with start-stop-daemon
 
Hi All,

I'm hosing game servers (Ravenshield) to our clan based upon the unreal2 engine, wine and Debian Squeeze.

I wrote a script to safely start/stop multiple instances of different game servers independently from each other. I used start-stop-daemon, which is a great stuff, although I've encountered some major issues:

1. It does not create the necessary pid file in the /var/run folder, therefore I can not find out whether the corresponding server is running or not.

2. I can not access to the start-stop-daemon as a user, only as root. It is a problem as the game admins can not start/stop/restart the servers, also it is difficult to interface it with a web-based control panel. I thought maybe DBUS could do that but it's not clear in my head how I would hook them up. Any idea?

Here is the script: http://pastebin.com/VmyyzHSV

Thanks for any help or useful advices.

cbtshare 01-31-2012 09:34 PM

as root can you manually issue the commands you want and a pid file appears?

agentgates 01-31-2012 11:48 PM

Hello,

I ran the command before as root with & switch but there was no pid file in the /var/run. I assumed the start-stop-daemon will resolve this issue. The strange thing I noticed it runs a wine process but in the process list it appears as UCC.exe and that is how I can refer to them to kill (killall UCC.exe). But naturally I don't want to kill all of them.

So I mean the process name should be "wine" and not "UCC.exe" as wine is the actual *nix process.

As for the pid directory the pids will be in a subdir:
drwxrwxr-x 2 games games 4096 Feb 1 05:17 ucc-servers

No matter how I start the process it doesn't work either "root" or "games".

cbtshare 02-01-2012 01:24 AM

is there an error message when you try to start the service and no pid is found?

Quote:

tail -f /var/log/messages

agentgates 02-01-2012 08:49 AM

No, nothing is in the log.

cbtshare 02-01-2012 11:01 AM

I am still trying to get as much info about this from you to see which part of the script is giving problem.

so since you cant start the process by doing service start or restart I am guessing you have to then killall process and then start it again and the pid file appears?

agentgates 02-01-2012 03:59 PM

Quote:

so since you cant start the process by doing service start or restart I am guessing you have to then killall process and then start it again
Correct.

Quote:

the pid file appears?
No, the pid file never appears when you run the command manually:
Code:

wine UCC.exe server &
It does return with the pid number in the stdout but the pid file never appears.

I just solved this part of my problems (after hours of headache) and here is the solution. I got the impression (after your helpful guidance) somehow wine "swallows" the pid file. I went back to start-stop-daemon and my original assumption that once if it asks for a --pidfile switch then it sould create it. I read the man again (this time more thoroughly) and it says if the pid file is not created then it can be enforced externally by --make-pid. So the --pidfile switch was not adequate in this case. Now it does it but it's still unclear why wine "swallows" it.

The other part of the problems (the #2 in my original post) is still unresolved. I could make a file that the web control panel can write and make a small process running as root that's keep reading the file and excecutes the script but this is a poor design. So I would rather do it with DBUS but it's not straightforward how it works.


All times are GMT -5. The time now is 11:38 AM.