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

View File

@ -0,0 +1,24 @@
<?php
/*
* This file is part of RaspiSMS.
*
* (c) Pierre-Lin Bonnemaison <plebwebsas@gmail.com>
*
* This source file is subject to the GPL-3.0 license that is bundled
* with this source code in the file LICENSE.
*/
namespace controllers\internals;
/**
* Class to call the console scripts
*/
class Console extends \descartes\InternalController
{
public function server ()
{
$server = new \daemons\Server();
}
}

View File

@ -1,5 +1,7 @@
<?php
namespace daemons;
/**
* Class defining the global structur of a Linux Daemon
*/

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";
}
}