An open API service indexing awesome lists of open source software.

https://github.com/takuya/php-daemonize-pcntl

php-daemonize-pcntl
https://github.com/takuya/php-daemonize-pcntl

daemon daemonize pcntl php

Last synced: over 1 year ago
JSON representation

php-daemonize-pcntl

Awesome Lists containing this project

README

          

# php-daemonize-pcntl

daemonize function by pcntl_fork.

## php daemon Daemonize all

Daemonize any process , written by php ( pcntl )

## installing

from Packagist
```shell
composer require takuya/php-daemonize-pcntl
```
from GitHub
```shell
name='php-daemonize-pcntl'
composer config repositories.$name \
vcs https://github.com/takuya/$name
composer require takuya/$name:master
composer install
```

## Examples

### function / Daemonize ( detach tty and parent PID=1)

```php
start(function () { sleep(1000); });
$m->stop();

```
### Run command as daemon
```php
start(function () { pcntl_exec('/usr/bin/sleep',[10]) });
```

## service (init.d)

this package help to make init.d service

run web server
### my-server.sh
```php
#!/usr/bin/env php
require_once 'vendor/autoload.php';
use Takuya\PhpDaemonize\PhpDaemonize;

$name = 'my-server';
// start stop
PhpDaemonize::run_func(function(){
pcntl_exec('/usr/bin/php',['artisan','serve'])
},$name);
```

start and stop
```shell
./my-server.sh start
./my-server.sh stop
```