Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Writing a Perl Daemon

by ikegami (Pope)
on Jul 28, 2005 at 06:20 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://478842]
[james28909]: i was more or less using a caveman to get the point across. we come from single cell organisms, and are now preparing to try to inhabit another planet. (please save me the morality of it lol)
[holli]: it's a german place. -tal is correct. the h is just a concession for hipsters ;-)
[erix]: haha
[erix]: I'll go with the hipsters this once ;)
[LanX]: the name is older than orthography and pronouncing standards ... which is normally the case, not many foundations after mid 19th century
[erix]: you hear, holli? :P
[holli]: I like the Hipster theorem better
erix scratches his beard
shmem .oO( alternative facts... )

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2017-12-15 15:53 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (435 votes). Check out past polls.