{"id":23359803,"url":"https://github.com/firehed/processmanager","last_synced_at":"2026-02-27T09:08:59.996Z","repository":{"id":9538494,"uuid":"11442112","full_name":"Firehed/ProcessManager","owner":"Firehed","description":"PHP Process Control tools","archived":false,"fork":false,"pushed_at":"2019-02-26T20:25:50.000Z","size":103,"stargazers_count":45,"open_issues_count":0,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-24T09:21:10.799Z","etag":null,"topics":["daemon","php","php-daemon","queue","worker-management"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Firehed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-16T06:12:12.000Z","updated_at":"2024-04-27T14:52:50.000Z","dependencies_parsed_at":"2022-07-13T07:20:30.975Z","dependency_job_id":null,"html_url":"https://github.com/Firehed/ProcessManager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2FProcessManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2FProcessManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2FProcessManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2FProcessManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Firehed","download_url":"https://codeload.github.com/Firehed/ProcessManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["daemon","php","php-daemon","queue","worker-management"],"created_at":"2024-12-21T11:12:01.403Z","updated_at":"2026-02-27T09:08:59.968Z","avatar_url":"https://github.com/Firehed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Process Control Tools\n\n## Requirements\n* `posix` and `pcntl` extensions\n* PHP5.4+ (Uses modern syntax)\n* Basic knowledge of PHP on the command line\n\n# Daemon\nA really useful tool with a very boring name. Daemonize your PHP scripts with two lines of code.\n\n\n## Usage\nCode:\n\n\t\u003c?php\n\t// Preferred:\n\trequire 'vendor/autoload.php'; // composer\n\tdeclare(ticks=1);\n    (new Firehed\\ProcessControl\\Daemon)\n        -\u003esetUser('sites')\n        -\u003esetPidFileLocation('/var/run/gearman-manager2.pid')\n        -\u003esetStdoutFileLocation(sys_get_temp_dir().'/my.log')\n        -\u003esetStdErrFileLocation('/dev/null')\n        -\u003esetProcessName(basename(__FILE__).' master process')\n        -\u003eautoRun();\n\t// The rest of your original script\n\nCLI:\n\n\tphp yourscript.php {status|start|stop|restart|reload|kill}\n\nYes, it's that simple.\n\n### Actions\n* Status: Check the status of the process. Returns:\n\t* 0 if running\n\t* 1 if dead but pidfile is hanging around\n\t* 3 if stopped\n* Start: Start the daemon\n* Stop: Stop the daemon gracefully via SIGTERM\n* Restart: Stop (if running) and start\n* Reload: Send SIGUSR1 to daemon (you need to implement a reload function, see below)\n* Kill: Kill the daemon via SIGKILL (kill -9)\n\n## Options\n* `setProcessName($string)`: Set the process name as it will appear in utilities such as `top`. This is only supported under PHP5.5+.\n* `setPidFileLocation($path)`: Specify the location of the pid file. This file stores the process id when the daemon is running, and goes away when the daemon stops.\n* `setStdoutFileLocation($path)`: File where anything that would have been written to `STDOUT` (`echo`, `print`, etc) goes.\n* `setStdErrFileLocation($path)`: File where anything that would have been written to `STDERR` goes. It appears that `display_errors` no longer writes to `STDERR` after daemonizing, so setting this to `/dev/null` is pretty safe.\n* `setUser($system_user)`: If you want to have the process run as a lower-security user, specify the username here. This is especially helpful if you start the daemon on system with `chkconfig` and `/etc/init.d`, since those run as root.\n\nTo come later(?):\n* Verbose output\n* Synchronous mode (do not daemonize for debugging)\n* Log file configuration\n\n## Useful tips\n\n* STDOUT (echo, print) is redirected to the log file.\n* The \"reload\" command won't do anything without installing a handler for SIGUSR1. Examples are due shortly.\n\n\n## Known Issues\n\n* STDERR doesn't appear to go anywhere, despite opening a logfile for it.\n* The script can't set up \"reload\" bindings automatically. This is a PHP limitation: \"The declare construct can also be used in the global scope, affecting all code following it (**however if the file with declare was included then it does not affect the parent file**)\". [http://docs.php.net/manual/en/control-structures.declare.php]()\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fprocessmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirehed%2Fprocessmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fprocessmanager/lists"}