File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 66use Illuminate \Process \InvokedProcess ;
77use Illuminate \Support \Facades \Process ;
88use Laravel \SerializableClosure \SerializableClosure ;
9+ use loophp \phposinfo \OsInfo ;
910
1011/**
1112 * The common handler of an AsyncTask; this can be a closure (will be wrapped inside AsyncTask) or an interface instance.
@@ -68,9 +69,20 @@ public function run(): void
6869 */
6970 public function start (): void
7071 {
71- // assume unix for now
72+ // prepare the runner command
7273 $ serializedTask = $ this ->toBase64Serial ();
73- $ this ->runnerProcess = Process::quietly ()->start ("php artisan async:run $ serializedTask " );
74+ $ baseCommand = "php artisan async:run $ serializedTask " ;
75+
76+ // then, specific actions depending on the runtime OS
77+ if (OsInfo::isWindows ()) {
78+ // basically, in windows, it is too tedioous to check whether we are in cmd or ps,
79+ // but we require cmd (ps won't work here), so might as well force cmd like this
80+ $ this ->runnerProcess = Process::quietly ()->start ("cmd /c start /b $ baseCommand " );
81+ return ;
82+ }
83+ // assume anything not windows to be unix
84+ // unix use nohup
85+ $ this ->runnerProcess = Process::quietly ()->start ("nohup $ baseCommand " );
7486 }
7587
7688 /**
You can’t perform that action at this time.
0 commit comments