first console using daemon
This commit is contained in:
parent
cd87c299dc
commit
e709ed91b7
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace daemons;
|
||||
|
||||
/**
|
||||
* Class defining the global structur of a Linux Daemon
|
||||
*/
|
||||
|
|
|
@ -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…
Reference in New Issue