Re: daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 6, 2010 at 11:21 PM, Tommy Pham <tommyhp2@xxxxxxxxx> wrote:

> Hi,
>
> Does anyone have a script running as daemon on Linux/Unix (variants) as
> part
> of your PHP application?  If so, what are you using to schedule the script
> to run? cron?
>

cron is one way to do it for scripts you schedule.  for real daemon
processes though ive recently deployed a php script on gentoo by leveraging
the init scripts.  essentially my program runs a while(true) and uses
pcntl_fork() to create worker children.  the parent process listens for
signals which are sent by an init script.  theres also a really nice
start-stop-daemon function in the init script library which backgrounds the
process for me and creates a pid lockfile.  really slick.

now i have an interface to my script like

/etc/init.d/php-service start

etc.  plus it ties right into the runlevel scripts, i just run

rc-update add php-service default

and the script will start when the box hits runlevel 3!

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux