File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -72,8 +72,7 @@ protected function restartHorizon(): self
72
72
{
73
73
$ this ->components ->info ('Change detected! Restarting horizon... ' );
74
74
75
- $ this ->horizonProcess ->stop ();
76
-
75
+ $ this ->stopHorizon ();
77
76
$ this ->startHorizon ();
78
77
79
78
return $ this ;
@@ -83,4 +82,26 @@ protected function isPhpFile(string $path): bool
83
82
{
84
83
return str_ends_with (strtolower ($ path ), '.php ' );
85
84
}
85
+
86
+ protected function stopHorizon (): void
87
+ {
88
+ $ this ->killStrayHorizonProcesses ();
89
+
90
+ $ this ->horizonProcess ->stop ();
91
+ }
92
+
93
+ protected function killStrayHorizonProcesses (): void
94
+ {
95
+ (Process::fromShellCommandline ('pgrep -P ' . $ this ->horizonProcess ->getPid ()))
96
+ ->run (function ($ type , $ output ) {
97
+ $ childPids = explode ("\n" , $ output );
98
+ foreach ($ childPids as $ childPid ) {
99
+ if (! $ childPid ) {
100
+ continue ;
101
+ }
102
+
103
+ (Process::fromShellCommandline ('kill ' . $ childPid ))->run ();
104
+ }
105
+ });
106
+ }
86
107
}
You can’t perform that action at this time.
0 commit comments