Starting a PHP Daemon Script sans CLI

49 views
Skip to first unread message

ashore

unread,
Apr 21, 2014, 5:00:43 PM4/21/14
to professi...@googlegroups.com
All, our open source package is in the hands of n users, some of them quite inexperienced. Some linux servers, some Windows.  Many are hosted, so they don't have ready access to CLI operation. I can't assume that all users are configured with pcntl.

Now I'm contemplating adding some websocket stuff to the mix, and the usual technique requires that the server component/script  be started via a CLI operation.

I'd really, really like to avoid CLI if at possible, and my take is that it's indeed feasible, provided that the following requirements - at least - are honored.

1.  There must be exactly one copy of the script in operation.
2.  The starting process must be atomic.
3.  There must be some termination  method, to ensure that the script doesn't run forever.
4.  The script must run disconnected; i.e., ignore_user_abort() set true.

I'm satisfied I know how to meet these requirements, but what I'm not sure of is how to script the start-up process.  I'll appreciate the collective wisdom here!

Robert Gonzalez

unread,
Apr 21, 2014, 9:08:16 PM4/21/14
to professional-php
Could you just add a script that runs as part of the normal startup collection but that could also be triggered manually if necessary? Something a la init scripts on linux.


--
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to professional-p...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Robert Gonzalez
   

ashore

unread,
Aug 29, 2014, 6:42:29 PM8/29/14
to professi...@googlegroups.com
Robert, thanks, but my users may not have the tech chops to do that; plenty of noobs in the bunch.  Which is why I'm looking for some simple-minded approach.

Now, for grins, I tried to exec() the would-be daemon, but nothing launched.;  some permissions lacking, I suppose.  Any thoughts on how I might get that to run, even though it might wind up running in my connection context only. 

Or, ????

AS

Arnie Shore

unread,
Sep 2, 2014, 11:11:02 PM9/2/14
to professi...@googlegroups.com

Plan B:  Do an ajax call to start the daemon, which can run ignoring user abort, with an OK time limit, and can ensure that only one copy is running.

I'll try this and report back result.  AS

--
You received this message because you are subscribed to a topic in the Google Groups "Professional PHP Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/professional-php/Jn-_xwDf5uw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to professional-p...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages