PHP code example of falc / robo-system-service

1. Go to this page and download the library: Download falc/robo-system-service 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/ */

    

falc / robo-system-service example snippets


class RoboFile extends \Robo\Tasks
{
    use Falc\Robo\Service\loadTasks;

    // ...
}

$startTask = $this->taskServiceStart()
    ->serviceManager('systemd')
    ->service('service1');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($startTask)
    ->run();

$stopTask = $this->taskServiceStop()
    ->serviceManager('systemd')
    ->service('service1');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($stopTask)
    ->run();

$restartTask = $this->taskServiceRestart()
    ->serviceManager('systemd')
    ->service('service1');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($restartTask)
    ->run();

$reloadTask = $this->taskServiceReload()
    ->serviceManager('systemd')
    ->service('service1');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($reloadTask)
    ->run();

$enableTask = $this->taskServiceEnable()
    ->serviceManager('systemd')
    ->service('service1');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($enableTask)
    ->run();

$disableTask = $this->taskServiceDisable()
    ->serviceManager('systemd')
    ->service('service1');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($disableTask)
    ->run();

$daemonReloadTask = $this->taskServiceDaemonReload()
    ->serviceManager('systemd');

$this->taskSshExec('remote.example.com')
    ->remoteDir('/home/user')
    ->printed(false) // Do not display output
    ->exec($daemonReloadTask)
    ->run();
 php
$this->taskServiceStart()
    ->serviceManager('systemd')
    ->service('service1')
    ->run();

$this->taskServiceStart('systemd', 'service1')->run();
 php
$this->taskServiceStop()
    ->serviceManager('systemd')
    ->service('service1')
    ->run();

$this->taskServiceStop('systemd', 'service1')->run();
 php
$this->taskServiceRestart()
    ->serviceManager('systemd')
    ->service('service1')
    ->run();

$this->taskServiceRestart('systemd', 'service1')->run();
 php
$this->taskServiceReload()
    ->serviceManager('systemd')
    ->service('service1')
    ->run();

$this->taskServiceReload('systemd', 'service1')->run();
 php
$this->taskServiceEnable()
    ->serviceManager('systemd')
    ->service('service1')
    ->run();

$this->taskServiceEnable('systemd', 'service1')->run();
 php
$this->taskServiceDisable()
    ->serviceManager('systemd')
    ->service('service1')
    ->run();

$this->taskServiceDisable('systemd', 'service1')->run();
 php
$this->taskServiceDaemonReload()
    ->serviceManager('systemd')
    ->run();

$this->taskServiceDaemonReload('systemd')->run();