mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
first console using daemon
This commit is contained in:
parent
cd87c299dc
commit
e709ed91b7
3 changed files with 69 additions and 0 deletions
43
daemons/Server.php
Normal file
43
daemons/Server.php
Normal 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";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue