PHP code example of hammerstone / laravel-pseudo-daemon
1. Go to this page and download the library: Download hammerstone/laravel-pseudo-daemon library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hammerstone / laravel-pseudo-daemon example snippets
class TestCommand extends Command
{
use \Hammerstone\PseudoDaemon\IsPseudoDaemon;
public function handle()
{
$this->runAsPseudoDaemon();
}
/**
* This is the main method that will be kept alive.
*/
public function process()
{
// All of your processing...
}
}
// Kernel.php
// Use the daemonize macro.
$schedule->command('test')->daemonize();
// Or use the underlying methods.
$schedule->command('test')
->everyMinute()
->runInBackground()
->withoutOverlapping();
public function restartWhenChanged()
{
// Restart whenever the git hash changes.
// https://stackoverflow.com/a/949391/1408651
return shell_exec('git rev-parse HEAD');
}