Last active
July 2, 2019 17:00
-
-
Save benedict-erwin/7f6ce8d0ae90dac7ad55067f52bb7761 to your computer and use it in GitHub Desktop.
Revisions
-
benedict-erwin revised this gist
Jul 2, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Run PHP Script as Daemon in Linux (ubuntu) with Upstart ## How to set it up: Create a config file for your phpdaemon at /etc/init/phpdaemon.conf ```conf -
benedict-erwin revised this gist
Jul 2, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## How to set it up: Create a config file for your phpdaemon at /etc/init/phpdaemon.conf ```conf # Info @@ -30,11 +30,11 @@ script end script ``` ## Starting & stopping your daemon: ``` sudo service phpdaemon start sudo service phpdaemon stop ``` ## Check if your daemon is running: ```sudo service myphpworker status``` -
benedict-erwin created this gist
Jul 2, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ ##How to set it up: Create a config file for your phpdaemon at /etc/init/phpdaemon.conf ```conf # Info description "PHP Daemon" author "Benedict E. Pranata" # Events start on startup stop on shutdown # Automatically respawn # respawn the job up to 10 times within a 5 second period. respawn respawn limit 10 5 # Check before running # exit if php script already running pre-start script if ps -ef | grep -v grep | grep phpdaemon; then stop; exit 0 fi end script # Run the script! # Note, in this example, if your PHP script returns # the string "ERROR", the daemon will stop itself. script [ $(exec /usr/bin/php -f /path/to/your/phpdaemon.php) = 'ERROR' ] && ( stop; exit 1; ) end script ``` ##Starting & stopping your daemon: ``` sudo service phpdaemon start sudo service phpdaemon stop ``` ##Check if your daemon is running: ```sudo service myphpworker status```