All Projects → Firehed → Processmanager

Firehed / Processmanager

Licence: mit
PHP Process Control tools

Projects that are alternatives of or similar to Processmanager

Linkliar
🔗 Link-Layer MAC spoofing GUI for macOS
Stars: ✭ 885 (+1958.14%)
Mutual labels:  daemon
Core
Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go.
Stars: ✭ 34 (-20.93%)
Mutual labels:  queue
Yii Queue
Queue extension for Yii 3.0
Stars: ✭ 38 (-11.63%)
Mutual labels:  queue
Leoric
PoC of fighting against force-stop kill process on Android
Stars: ✭ 946 (+2100%)
Mutual labels:  daemon
Storage Based Queue
Javascript queue library with persistent storage based queue mechanism for the browsers environments. Specially designed for offline.
Stars: ✭ 33 (-23.26%)
Mutual labels:  queue
Sidekiq Job Php
Push and schedule jobs to Sidekiq from PHP
Stars: ✭ 34 (-20.93%)
Mutual labels:  queue
Python Microjet
Python 3 asynchronous microservices framework powered by asyncio.
Stars: ✭ 11 (-74.42%)
Mutual labels:  daemon
Deluge
Deluge BitTorrent client - Git mirror, PRs only
Stars: ✭ 1,012 (+2253.49%)
Mutual labels:  daemon
Cockburst
一个高性能,可靠,异步的本地持久化队列实现;重启JVM、重启服务器、或者强制KILL进程时,队列里的数据不丢失;
Stars: ✭ 33 (-23.26%)
Mutual labels:  queue
Laravel Queue Database Ph4
Laravel Database Queue with Optimistic locking
Stars: ✭ 37 (-13.95%)
Mutual labels:  queue
Whatpulse
WhatPulse reverse engineered
Stars: ✭ 30 (-30.23%)
Mutual labels:  daemon
Laravel Couchbase
Couchbase providers for Laravel
Stars: ✭ 31 (-27.91%)
Mutual labels:  queue
Yii2 Queue
Yii2 Queue Extension. Supports DB, Redis, RabbitMQ, Beanstalk and Gearman
Stars: ✭ 977 (+2172.09%)
Mutual labels:  queue
Ipmonitor
IP Monitor is a simple application which monitors your public IP address for changes and lets you set different kinds of notifications such as email, audio, pop up or executing a command
Stars: ✭ 28 (-34.88%)
Mutual labels:  daemon
Redux Queue
Higher order reducer to handle execution order of actions
Stars: ✭ 39 (-9.3%)
Mutual labels:  queue
Go Queue
Multi backend queues for Golang
Stars: ✭ 15 (-65.12%)
Mutual labels:  queue
Azure.data.wrappers
Azure Storage Simplified
Stars: ✭ 34 (-20.93%)
Mutual labels:  queue
Libgenerics
libgenerics is a minimalistic and generic library for C basic data structures.
Stars: ✭ 42 (-2.33%)
Mutual labels:  queue
Toro
Multithreaded message processing on Postgres
Stars: ✭ 39 (-9.3%)
Mutual labels:  queue
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-18.6%)
Mutual labels:  queue

Process Control Tools

Requirements

  • posix and pcntl extensions
  • PHP5.4+ (Uses modern syntax)
  • Basic knowledge of PHP on the command line

Daemon

A really useful tool with a very boring name. Daemonize your PHP scripts with two lines of code.

Usage

Code:

<?php
// Preferred:
require 'vendor/autoload.php'; // composer
declare(ticks=1);
(new Firehed\ProcessControl\Daemon)
    ->setUser('sites')
    ->setPidFileLocation('/var/run/gearman-manager2.pid')
    ->setStdoutFileLocation(sys_get_temp_dir().'/my.log')
    ->setStdErrFileLocation('/dev/null')
    ->setProcessName(basename(__FILE__).' master process')
    ->autoRun();
// The rest of your original script

CLI:

php yourscript.php {status|start|stop|restart|reload|kill}

Yes, it's that simple.

Actions

  • Status: Check the status of the process. Returns:
    • 0 if running
    • 1 if dead but pidfile is hanging around
    • 3 if stopped
  • Start: Start the daemon
  • Stop: Stop the daemon gracefully via SIGTERM
  • Restart: Stop (if running) and start
  • Reload: Send SIGUSR1 to daemon (you need to implement a reload function, see below)
  • Kill: Kill the daemon via SIGKILL (kill -9)

Options

  • setProcessName($string): Set the process name as it will appear in utilities such as top. This is only supported under PHP5.5+.
  • 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.
  • setStdoutFileLocation($path): File where anything that would have been written to STDOUT (echo, print, etc) goes.
  • 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.
  • 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.

To come later(?):

  • Verbose output
  • Synchronous mode (do not daemonize for debugging)
  • Log file configuration

Useful tips

  • STDOUT (echo, print) is redirected to the log file.
  • The "reload" command won't do anything without installing a handler for SIGUSR1. Examples are due shortly.

Known Issues

  • STDERR doesn't appear to go anywhere, despite opening a logfile for it.
  • 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].