Corrected Lunch to Launch

This commit is contained in:
Zi Xing 2021-12-09 22:37:56 -05:00
parent a5252ca355
commit e746ae610c
4 changed files with 53 additions and 53 deletions

View File

@ -29,14 +29,14 @@ documentation will explain what sections can be configured, and examples. The op
provided by `ssm` are similar to what `systemd` provides.
### Lunch Condition
### Launch Condition
A lunch condition is applied to many sections of the file that you can optionally add,
this includes the main `start` condition that represents the main execution point of
your service configuration, there can be many other lunch conditions that can be
executed for example before and after your `start` condition runs, or before and after
restart and stop conditions. Allowing you to fully customize and handle the service
execution flow. Below is a table of options that a Lunch Condition section can consist
execution flow. Below is a table of options that a Launch Condition section can consist
of but note that some options may only be applicable to `start` and other lunch
conditions. Not all options are required.

View File

@ -8,7 +8,7 @@
use ssm\Abstracts\Time;
use ssm\Utilities\Parser;
class LunchCondition
class LaunchCondition
{
/**
* The main execution point of the lunch condition
@ -194,23 +194,23 @@
* Constructs object from an array representation
*
* @param array $data
* @return LunchCondition
* @return LaunchCondition
*/
public static function fromArray(array $data): LunchCondition
public static function fromArray(array $data): LaunchCondition
{
$LunchConditionObject = new LunchCondition();
$LaunchConditionObject = new LaunchCondition();
if(isset($data['Exec']))
$LunchConditionObject->Exec = $data['Exec'];
$LaunchConditionObject->Exec = $data['Exec'];
if(isset($data['Args']))
$LunchConditionObject->Arguments = Parser::parseArgumentsString($data['Args']);
$LaunchConditionObject->Arguments = Parser::parseArgumentsString($data['Args']);
if(isset($data['Env']))
$LunchConditionObject->EnvironmentVariables = Parser::parseArgumentsString($data['Env']);
$LaunchConditionObject->EnvironmentVariables = Parser::parseArgumentsString($data['Env']);
if(isset($data['Cwd']))
$LunchConditionObject->CurrentWorkingDirectory = $data['Cwd'];
$LaunchConditionObject->CurrentWorkingDirectory = $data['Cwd'];
if(isset($data['Restart']))
{
@ -221,36 +221,36 @@
case RestartCondition::Always:
case RestartCondition::UnlessStopped:
case RestartCondition::OnSuccess:
$LunchConditionObject->Restart = strtolower($data['Restart']);
$LaunchConditionObject->Restart = strtolower($data['Restart']);
break;
default:
$LunchConditionObject->Restart = RestartCondition::No;
$LaunchConditionObject->Restart = RestartCondition::No;
}
}
if(isset($data['MaxFailureRestarts']))
$LunchConditionObject->MaxFailureRestarts = (int)$data['MaxFailureRestarts'];
$LaunchConditionObject->MaxFailureRestarts = (int)$data['MaxFailureRestarts'];
if(isset($data['MaxAutomaticRestarts']))
$LunchConditionObject->MaxAutomaticRestarts = (int)$data['MaxAutomaticRestarts'];
$LaunchConditionObject->MaxAutomaticRestarts = (int)$data['MaxAutomaticRestarts'];
if(isset($data['TimeoutStartSec']))
$LunchConditionObject->TimeoutStartSeconds = (int)$data['TimeoutStartSec'];
$LaunchConditionObject->TimeoutStartSeconds = (int)$data['TimeoutStartSec'];
if(isset($data['TimeoutStopSec']))
$LunchConditionObject->TimeoutStopSeconds = (int)$data['TimeoutStopSec'];
$LaunchConditionObject->TimeoutStopSeconds = (int)$data['TimeoutStopSec'];
if(isset($data['RuntimeMaxSec']))
$LunchConditionObject->RuntimeMaxSeconds = (int)$data['RuntimeMaxSec'];
$LaunchConditionObject->RuntimeMaxSeconds = (int)$data['RuntimeMaxSec'];
if(isset($data['SuccessExitStatus']))
{
foreach(explode(' ', $data['SuccessExitStatus']) as $item)
{
if(in_array((int)$item, $LunchConditionObject->SuccessExitStatus) == false)
if(in_array((int)$item, $LaunchConditionObject->SuccessExitStatus) == false)
{
$LunchConditionObject->SuccessExitStatus[] = (int)$item;
$LaunchConditionObject->SuccessExitStatus[] = (int)$item;
}
}
}
@ -259,45 +259,45 @@
{
foreach(explode(' ', $data['ErrorExitStatus']) as $item)
{
if(in_array((int)$item, $LunchConditionObject->ErrorExitStatus) == false)
if(in_array((int)$item, $LaunchConditionObject->ErrorExitStatus) == false)
{
$LunchConditionObject->ErrorExitStatus[] = (int)$item;
$LaunchConditionObject->ErrorExitStatus[] = (int)$item;
}
}
}
if(isset($data['RestartPreventExitStatus']))
{
$LunchConditionObject->RestartPreventExitStatus = [];
$LaunchConditionObject->RestartPreventExitStatus = [];
foreach(explode(' ', $data['RestartPreventExitStatus']) as $item)
{
if(in_array((int)$item, $LunchConditionObject->RestartPreventExitStatus) == false)
if(in_array((int)$item, $LaunchConditionObject->RestartPreventExitStatus) == false)
{
$LunchConditionObject->RestartPreventExitStatus[] = (int)$item;
$LaunchConditionObject->RestartPreventExitStatus[] = (int)$item;
}
}
}
if(isset($data['RestartForceExitStatus']))
{
$LunchConditionObject->RestartForceExitStatus = [];
$LaunchConditionObject->RestartForceExitStatus = [];
foreach(explode(' ', $data['RestartForceExitStatus']) as $item)
{
if(in_array((int)$item, $LunchConditionObject->RestartForceExitStatus) == false)
if(in_array((int)$item, $LaunchConditionObject->RestartForceExitStatus) == false)
{
$LunchConditionObject->RestartForceExitStatus[] = (int)$item;
$LaunchConditionObject->RestartForceExitStatus[] = (int)$item;
}
}
}
if(isset($data['LogStdout']))
$LunchConditionObject->LogStdout = (bool)$data['LogStdout'];
$LaunchConditionObject->LogStdout = (bool)$data['LogStdout'];
if(isset($data['LogStderr']))
$LunchConditionObject->LogStderr = (bool)$data['LogStderr'];
$LaunchConditionObject->LogStderr = (bool)$data['LogStderr'];
return $LunchConditionObject;
return $LaunchConditionObject;
}
}

View File

@ -13,77 +13,77 @@
/**
* The main execution point for the service
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $Start;
/**
* The lunch condition before starting the main execution point
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $StartPre;
/**
* The lunch condition after starting the main execution point
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $StartPost;
/**
* The lunch condition to execute when the service stops
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $Stop;
/**
* The lunch condition to execute before running the stop condition
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $StopPre;
/**
* The lunch condition to execute after running the stop condition
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $StopPost;
/**
* The lunch condition to execute when the service has successfully loaded
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $Reload;
/**
* The lunch condition to execute before the service reloads
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $ReloadPre;
/**
* The lunch condition to execute after the service successfully reloads
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $ReloadPost;
/**
* The lunch condition to execute after the service fails
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $OnFailure;
/**
* The lunch condition to execute after the service has successfully executed and exited
*
* @var LunchCondition|null
* @var LaunchCondition|null
*/
public $OnSuccess;
@ -166,37 +166,37 @@
$ServiceConfigurationObject = new ServiceConfiguration();
if(isset($data['start']))
$ServiceConfigurationObject->Start = LunchCondition::fromArray($data['start']);
$ServiceConfigurationObject->Start = LaunchCondition::fromArray($data['start']);
if(isset($data['start_pre']))
$ServiceConfigurationObject->StartPre = LunchCondition::fromArray($data['start_pre']);
$ServiceConfigurationObject->StartPre = LaunchCondition::fromArray($data['start_pre']);
if(isset($data['start_post']))
$ServiceConfigurationObject->StartPost = LunchCondition::fromArray($data['start_post']);
$ServiceConfigurationObject->StartPost = LaunchCondition::fromArray($data['start_post']);
if(isset($data['stop']))
$ServiceConfigurationObject->Stop = LunchCondition::fromArray($data['stop']);
$ServiceConfigurationObject->Stop = LaunchCondition::fromArray($data['stop']);
if(isset($data['stop_pre']))
$ServiceConfigurationObject->StopPre = LunchCondition::fromArray($data['stop_pre']);
$ServiceConfigurationObject->StopPre = LaunchCondition::fromArray($data['stop_pre']);
if(isset($data['stop_post']))
$ServiceConfigurationObject->StopPost = LunchCondition::fromArray($data['stop_post']);
$ServiceConfigurationObject->StopPost = LaunchCondition::fromArray($data['stop_post']);
if(isset($data['reload']))
$ServiceConfigurationObject->Reload = LunchCondition::fromArray($data['reload']);
$ServiceConfigurationObject->Reload = LaunchCondition::fromArray($data['reload']);
if(isset($data['reload_pre']))
$ServiceConfigurationObject->ReloadPre = LunchCondition::fromArray($data['reload_pre']);
$ServiceConfigurationObject->ReloadPre = LaunchCondition::fromArray($data['reload_pre']);
if(isset($data['reload_post']))
$ServiceConfigurationObject->Reload = LunchCondition::fromArray($data['reload_post']);
$ServiceConfigurationObject->Reload = LaunchCondition::fromArray($data['reload_post']);
if(isset($data['on_failure']))
$ServiceConfigurationObject->OnFailure = LunchCondition::fromArray($data['on_failure']);
$ServiceConfigurationObject->OnFailure = LaunchCondition::fromArray($data['on_failure']);
if(isset($data['on_success']))
$ServiceConfigurationObject->OnSuccess = LunchCondition::fromArray($data['on_success']);
$ServiceConfigurationObject->OnSuccess = LaunchCondition::fromArray($data['on_success']);
return $ServiceConfigurationObject;
}

View File

@ -72,7 +72,7 @@
},
{
"required": true,
"file": "Objects/LunchCondition.php"
"file": "Objects/LaunchCondition.php"
},
{
"required": true,