I have a problem deploying my project with envoyer which executes an artisan-command I created.
The command gets all my users, performs another artisan command ($this->call('command')
) and performs it actions by iterating through all the users.
The problems lies here:
foreach($usernames as $username) {
shell_exec('php ' . base_path('artisan') . ' command ' . $username . ' > /dev/null 2>/dev/null &');
}
This command starts a script in the background. Its getting executed without any problems manually and doesn't end in a timeout (takes about 1s~ to execute) but in envoyer it wont stop running in the deploying step and fails in a timeout altough it executes flawless.
Additional informations:
For the reason why i'm running the script in the background:
The script im starting opens a socket which he will listen 24/7 until
the user cancel it manually.
I've just created a smaller example to make sure it's all working fine:
File
forever.php
will keep an infinite loop printing something every 5 seconds:File
script.php
will call multiple instances offorever.php
and detach from the parent process (same as what you did):When executing
php script.php
, obviously there's 5 instances offorever.php
running. So your code seems fine (the part you've shown).The only things I can think of in your case are:
Hope it helps, if you need more help please provide some more information.