Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Writing a Perl Daemon

by ikegami (Patriarch)
on Jul 28, 2005 at 06:20 UTC ( [id://478842]=note: print w/replies, xml ) Need Help??


in reply to Writing a Perl Daemon

(B) Try to flock a lockfile without blocking. Exit if you didn't get the lock.

Alternatively, if your application is an IP server which always listens on the same port, forget the lockfile and exit if you can't create the server socket. You can't create two sockets on the same port, so the socket will act as the lockfile.

(C) Launch it in your OS's startup script.

(D) Create a cron job that starts the script periodically. (B) will make sure only one is running.

Update: By the way, you might want to have the script check for the presence of a specific file (perhaps called "no_start") at startup. If the file exists, then exit immediately. That will allow you to kill the server to do maintenance without worrying about it restarting itself.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found