Topic awaiting preservation: Java/Perl/Python/C++ - Socket Server Daemon ? (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: Brisbane, Australia |
posted 08-29-2004 17:32
I'm writing my own TCP socket server, I know there are a lot of free socket servers out there, but it sounded like a fun thing to do. Anyways, I'd like to run it on my web server (Dreamhost : Debian Linux) which supports Java, but not Servlets or JSP. |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 08-29-2004 19:06
The Perl documentation of the fork() function says that killing the parent will kill all the children. So I guess Perl is not a solution to your problem. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 08-29-2004 21:01
Actually usually if you just start a java (or any type of app) with the ampersand after it in an SSH session it won't die with the session. |
Paranoid (IV) Inmate From: Brisbane, Australia |
posted 08-29-2004 21:22
<edit> |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 08-29-2004 22:24
Check this out for info on processes in Unix. (according to that you have to use the nohup command so the process stays alive but I've done this with just an ampersand and it worked for me.) |
Paranoid (IV) Inmate From: Brisbane, Australia |
posted 08-29-2004 23:13
I'd say when the box gets rebooted as apache restarting shouldn't effect anything as it's not connecting to anything else at the moment, although it'll hook into a MySQL database at some point, but I'll deal with those issues as they arise. |
Paranoid (IV) Inmate From: Brisbane, Australia |
posted 08-30-2004 06:59
Reading through the PHP manual, it appears as if I can use the exec() command to do what I want. I can simply check the list of currently running processes and if I can't identify the server from the output, then I can simply start it again. If I setup the client to run through this routine whenever it fails to connect to the server everything should work more or less seamlessly given enough delay time between each connection attempt. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 08-30-2004 18:30
Generally you can do this fairly easily with the following command |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 08-30-2004 19:01
Have a look at the screen documentation - that should allow you to put a process into the background, which will stay there, until you kill it. |
Paranoid (IV) Inmate From: [s]underwater[/s] under-snow in Juneau |
posted 08-30-2004 19:57
...just a little tip about backgrounding a process. If your command/program has output that would usually go to standard out (terminal) you will need to redirect it like so ' yourcommand > output.txt & ' or your proccess will die. Also, if there is a chance of generating an error message you will need to redirect stnderror. This will write it to the same file as standard out- ' yourcommand >& output.txt & ' |
Paranoid (IV) Inmate From: Brisbane, Australia |
posted 08-31-2004 17:56
Thanks for the advice everyone. I really appreciate it. |