Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: making a perl script TSR? (on linux)

by Roger (Parson)
on Aug 20, 2005 at 00:35 UTC ( [id://485337]=note: print w/replies, xml ) Need Help??


in reply to making a perl script TSR? (on linux)

Have a look at the module Net::Server, it has pretty much all you need to write a network server daemon.

Should you want to kill your daemon cleanly, create a signal handler in the daemon that does a graceful shutdown, and have the program, when you run with '-k' flag, to send a signal to the daemon, which then initiates the shutdown procedure.

You may also want to look at modules like Unix::Process (really just ps -ef) to discover the PID of the daemon process.

You can also create a /var/lock/myserver.lock file as well when the server first goes TSR, that contains the PID of the server process. The program later (in kill mode) will read this file to get the PID, validate the PID using Unix::Process to make sure it is still running, then send the kill signal to the server to initiate a clean shutdown.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://485337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found