Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: apache2 and system ... cotinued from 2004

by holandes777 (Scribe)
on Aug 20, 2009 at 18:18 UTC ( [id://790163]=note: print w/replies, xml ) Need Help??


in reply to apache2 and system ... cotinued from 2004

This is not strictly related but the answer may help others so I'll ask here:
 
Net:Server::Daemonize writes a .pid file with the process number. Very useful becasue one can read that and then do a kill -2 (that process #) to stop the daemon (the .pid file is deleted as well).
 
BUT ... I am having permissions problems with reading and writing the .pid file when I execute through apache. I'm running apache on ubuntu. The daemos runs from /usr/lib/cgi-bin. The apache user is www-data. I created a subdirectory /usr/lib/cgi-bin/pids and did a sudo chown www-data:www-data pids plus sudo chmod 777 pids.
 
The daemon dies at startup (even from the command line). May I request help? Where should I be writting the pids to?
  • Comment on Re: apache2 and system ... cotinued from 2004

Replies are listed 'Best First'.
Re^2: apache2 and system ... cotinued from 2004
by afoken (Chancellor) on Aug 22, 2009 at 16:04 UTC

    I would delegate daemon management to an external tool, like daemontools. As a nice side effect, this completely eliminates the need for PID files. The apache handler would simply invoke the svc command with proper arguments, e.g. system('/command/svc','-u','/service/mydaemon'), or more likely, invoke it via sudo so apache does not run as root: system('/usr/bin/sudo','/command/svc','-u','/service/mydaemon'). The daemon does not need any daemonizing code, you write it as a simple foreground command line tool, the daemontools take care of managing the process, including backgrounding, error logging, signals, restarts, changing user and group id, environment, and so on. See http://thedjbway.org/daemontools.html for a human readable introduction.

    (And please don't chmod 777 any file or directory without a VERY good reason, especially not on systems connected to any kind of network.)

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found