first console using daemon

This commit is contained in:
osaajani 2019-12-08 02:33:53 +01:00
parent cd87c299dc
commit e709ed91b7
3 changed files with 69 additions and 0 deletions

43
daemons/Server.php Normal file
View file

@ -0,0 +1,43 @@
<?php
namespace daemons;
/**
* Main daemon class
*/
class Server extends AbstractDaemon
{
public function __construct()
{
//Construct the server and add SIGUSR1 and SIGUSR2
parent::__construct("server", [SIGUSR1, SIGUSR2]);
//Start the daemon
parent::start ();
}
public function run()
{
// Le code qui s'exécute infiniment
echo "On tourne !\n";
sleep ( 5 );
}
public function on_start()
{
echo "Démarrage du processus avec le pid " . getmypid () . "\n";
}
public function on_stop()
{
echo "Arrêt du processus avec le pid " . getmypid () . "\n";
}
public function handle_other_signals($signal)
{
echo "Signal non géré par la classe Daemon : " . $signal . "\n";
}
}