-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SimulateSupervisorDownTime command (#1)
* Added the `supervisor:downtime:simulate` command to simulate supervisor downtime detection and check if everything is correctly configured.
- Loading branch information
Showing
14 changed files
with
265 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="Laravel and similar phpmd ruleset" | ||
xmlns="http://pmd.sf.net/ruleset/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" | ||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> | ||
<description>Written using this resource : https://phpmd.org/rules/index.html</description> | ||
<!-- clean code rules --> | ||
<rule ref="rulesets/cleancode.xml"> | ||
<exclude name="StaticAccess"/> | ||
<exclude name="ElseExpression"/> | ||
<exclude name="BooleanArgumentFlag"/> | ||
</rule> | ||
<!-- code size rules --> | ||
<rule ref="rulesets/codesize.xml"> | ||
<exclude name="TooManyPublicMethods"/> | ||
<exclude name="TooManyMethods"/> | ||
<exclude name="ExcessiveClassComplexity"/> | ||
</rule> | ||
<rule ref="rulesets/codesize.xml/TooManyPublicMethods"> | ||
<properties> | ||
<property name="maxmethods" value="20"/> | ||
</properties> | ||
</rule> | ||
<rule ref="rulesets/codesize.xml/TooManyMethods"> | ||
<properties> | ||
<property name="maxmethods" value="30"/> | ||
</properties> | ||
</rule> | ||
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity"> | ||
<properties> | ||
<property name="maximum" value="60"/> | ||
</properties> | ||
</rule> | ||
<!-- controversial rules --> | ||
<rule ref="rulesets/controversial.xml"/> | ||
<!-- design rules --> | ||
<rule ref="rulesets/design.xml"> | ||
<exclude name="CouplingBetweenObjects"/> | ||
<exclude name="NumberOfChildren"/> | ||
</rule> | ||
<!-- naming rules --> | ||
<rule ref="rulesets/naming.xml"> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
name="Laravel and similar phpmd ruleset" | ||
xmlns="http://pmd.sf.net/ruleset/1.0.0" | ||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" | ||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> | ||
<description>Written using this resource : https://phpmd.org/rules/index.html</description> | ||
<!-- clean code rules --> | ||
<rule ref="rulesets/cleancode.xml"> | ||
<exclude name="StaticAccess"/> | ||
<exclude name="ElseExpression"/> | ||
<exclude name="BooleanArgumentFlag"/> | ||
</rule> | ||
<!-- code size rules --> | ||
<rule ref="rulesets/codesize.xml"> | ||
<exclude name="TooManyPublicMethods"/> | ||
<exclude name="TooManyMethods"/> | ||
<exclude name="ExcessiveClassComplexity"/> | ||
</rule> | ||
<rule ref="rulesets/codesize.xml/TooManyPublicMethods"> | ||
<properties> | ||
<property name="maxmethods" value="20"/> | ||
</properties> | ||
</rule> | ||
<rule ref="rulesets/codesize.xml/TooManyMethods"> | ||
<properties> | ||
<property name="maxmethods" value="30"/> | ||
</properties> | ||
</rule> | ||
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity"> | ||
<properties> | ||
<property name="maximum" value="60"/> | ||
</properties> | ||
</rule> | ||
<!-- controversial rules --> | ||
<rule ref="rulesets/controversial.xml"/> | ||
<!-- design rules --> | ||
<rule ref="rulesets/design.xml"> | ||
<exclude name="CouplingBetweenObjects"/> | ||
<exclude name="NumberOfChildren"/> | ||
</rule> | ||
<!-- naming rules --> | ||
<rule ref="rulesets/naming.xml"> | ||
<exclude name="LongClassName"/> | ||
<exclude name="ShortVariable"/> | ||
<exclude name="LongVariable"/> | ||
<exclude name="ShortMethodName"/> | ||
<exclude name="BooleanGetMethodName"/> | ||
</rule> | ||
<rule ref="rulesets/naming.xml/ShortVariable" | ||
since="0.2" | ||
message="Avoid variables with short names like {0}. Configured minimum length is {1}." | ||
class="PHPMD\Rule\Naming\ShortVariable" | ||
externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable"> | ||
<priority>3</priority> | ||
<properties> | ||
<property name="minimum" description="Minimum length for a variable, property or parameter name" value="3"/> | ||
<property name="exceptions" value="id,js,uu,ii,oo"/> | ||
</properties> | ||
</rule> | ||
<rule ref="rulesets/naming.xml/ShortMethodName"> | ||
<properties> | ||
<property name="exceptions" value="up,to,at"/> | ||
</properties> | ||
</rule> | ||
<!-- unused code rules --> | ||
<rule ref="rulesets/unusedcode.xml"/> | ||
<exclude name="ShortVariable"/> | ||
<exclude name="LongVariable"/> | ||
<exclude name="ShortMethodName"/> | ||
<exclude name="BooleanGetMethodName"/> | ||
</rule> | ||
<rule ref="rulesets/naming.xml/ShortVariable" | ||
since="0.2" | ||
message="Avoid variables with short names like {0}. Configured minimum length is {1}." | ||
class="PHPMD\Rule\Naming\ShortVariable" | ||
externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable"> | ||
<priority>3</priority> | ||
<properties> | ||
<property name="minimum" description="Minimum length for a variable, property or parameter name" value="3"/> | ||
<property name="exceptions" value="id,js,uu,ii,oo"/> | ||
</properties> | ||
</rule> | ||
<rule ref="rulesets/naming.xml/ShortMethodName"> | ||
<properties> | ||
<property name="exceptions" value="up,to,at"/> | ||
</properties> | ||
</rule> | ||
<!-- unused code rules --> | ||
<rule ref="rulesets/unusedcode.xml"/> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Okipa\LaravelSupervisorDowntimeNotifier\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Okipa\LaravelSupervisorDowntimeNotifier\SupervisorDowntimeNotifier; | ||
|
||
class SimulateSupervisorDownTime extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'supervisor:downtime:simulate'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Simulate supervisor downtime for testing purpose.'; | ||
|
||
/** @throws \Okipa\LaravelSupervisorDowntimeNotifier\Exceptions\SupervisorDownProcessesDetected */ | ||
public function handle(): void | ||
{ | ||
$fakeDownProcesses = collect([[],[]]); | ||
$notification = (new SupervisorDowntimeNotifier)->getDownProcessesNotification($fakeDownProcesses, true); | ||
(new SupervisorDowntimeNotifier)->getNotifiable()->notify($notification); | ||
$onDownProcesses = (new SupervisorDowntimeNotifier)->getDownProcessesCallback(); | ||
if ($onDownProcesses) { | ||
$onDownProcesses($fakeDownProcesses, true); | ||
} | ||
} | ||
} |
Oops, something went wrong.