|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace SystemCtl\Template\Section; |
| 4 | + |
| 5 | +/** |
| 6 | + * ServiceSection |
| 7 | + * |
| 8 | + * @method ServiceSection setType(string $type) Configures the unit process startup type |
| 9 | + * @method ServiceSection setEnvironment(array $env) Specify a list of environment variables |
| 10 | + * @method ServiceSection setEnvironmentFile(string $envFile) Specifiy a file with environment variables |
| 11 | + * @method ServiceSection setExecStart(string $execStart) Specifies commands or scripts to be executed when started |
| 12 | + * @method ServiceSection setExecStop(string $execStop) Specifies commands or scripts to be executed when stopped |
| 13 | + * @method ServiceSection setExecReload(string $execReload) Specifies commands or scripts to be executed when reloaded |
| 14 | + * @method ServiceSection setRestart(string $restart) Restart service of the process exists |
| 15 | + * @method ServiceSection setRemainsAfterExit(bool $rae) Consider service as active when all processes existed |
| 16 | + * @method ServiceSection setPIDFile(string $pidFile) Absolute file name pointing to the PID file of this daemon |
| 17 | + * |
| 18 | + * @method string getType() |
| 19 | + * @method array getEnvironment() |
| 20 | + * @method string getEnvironmentFile() |
| 21 | + * @method string getExecStart() |
| 22 | + * @method string getExecStop() |
| 23 | + * @method string getExecReload() |
| 24 | + * @method string getRestart() |
| 25 | + * @method bool shouldRemainsAfterExit() |
| 26 | + * @method string getPIDFile() |
| 27 | + * |
| 28 | + * @package SystemCtl\Template\Section |
| 29 | + * @author icanhazstring <[email protected]> |
| 30 | + */ |
| 31 | +class ServiceSection extends AbstractSection |
| 32 | +{ |
| 33 | + protected const PROPERTIES = [ |
| 34 | + 'Type', |
| 35 | + 'Environment', |
| 36 | + 'EnvironmentFile', |
| 37 | + 'ExecStart', |
| 38 | + 'ExecStop', |
| 39 | + 'ExecReload', |
| 40 | + 'Restart', |
| 41 | + 'RemainsAfterExit', |
| 42 | + 'PIDFile' |
| 43 | + ]; |
| 44 | + |
| 45 | + /** |
| 46 | + * The default value. The process started with ExecStart is the main process of the service. |
| 47 | + */ |
| 48 | + public const TYPE_SIMPLE = 'simple'; |
| 49 | + /** |
| 50 | + * The process started with ExecStart spawns a child process that becomes the main process of the service. |
| 51 | + * The parent process exits when the startup is complete. |
| 52 | + */ |
| 53 | + public const TYPE_FORKING = 'forking'; |
| 54 | + /** |
| 55 | + * This type is similar to simple, but the process exits before starting consequent units. |
| 56 | + */ |
| 57 | + public const TYPE_ONESHOT = 'oneshot'; |
| 58 | + /** |
| 59 | + * This type is similar to simple, but consequent units are started only after the main process gains a D-Bus name. |
| 60 | + */ |
| 61 | + public const TYPE_DBUS = 'dbus'; |
| 62 | + /** |
| 63 | + * This type is similar to simple, but consequent units are started only |
| 64 | + * after a notification message is sent via the sd_notify() function. |
| 65 | + */ |
| 66 | + public const TYPE_NOTIFY = 'notify'; |
| 67 | + /** |
| 68 | + * Similar to simple, the actual execution of the service binary is delayed until |
| 69 | + * all jobs are finished, which avoids mixing the status output with shell output of services. |
| 70 | + */ |
| 71 | + public const TYPE_IDLE = 'idle'; |
| 72 | + |
| 73 | + /** |
| 74 | + * List of all possible unit types |
| 75 | + */ |
| 76 | + public const TYPES = [ |
| 77 | + self::TYPE_SIMPLE, |
| 78 | + self::TYPE_FORKING, |
| 79 | + self::TYPE_ONESHOT, |
| 80 | + self::TYPE_DBUS, |
| 81 | + self::TYPE_NOTIFY, |
| 82 | + self::TYPE_IDLE |
| 83 | + ]; |
| 84 | +} |
0 commit comments