Last active
January 30, 2018 15:13
-
-
Save jozefcipa/78a68bcd0e837baaed71c0ce6b0268f6 to your computer and use it in GitHub Desktop.
Revisions
-
jozefcipa revised this gist
Jan 30, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ queue() { # If file not exists launch program (for the first time) if [ ! -f /tmp/my_queue.pid ] then queue; fi -
jozefcipa revised this gist
Jan 30, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ # Define program to run queue() { cd /path/to/your/project && php artisan queue:work & echo $! > /tmp/my_queue.pid } # If file not exists launch program (for the first time) -
jozefcipa revised this gist
Jan 30, 2018 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,22 +8,22 @@ # * * * * * /path/to/your/project/watcher.sh # Schedules watcher to run every minute # Define program to run queue() { cd /path/to/your/project && nohup php artisan queue:work & echo $! > /tmp/my_queue.pid } # If file not exists launch program (for the first time) if [ ! -f /tmp/my_queue.pid ] then cmd1; fi # Check if process with given ID (/tmp/my_queue.pid) is running # If not, launch again if [ ! -d /proc/$(</tmp/my_queue.pid) ] then queue; # launch script now=`date`; # Store current date echo "$now - relaunching" >> /path/to/your/project/watcher.log # Log date of re-run -
jozefcipa created this gist
Jan 30, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash # Process watcher # Watches for processes if they run, if not, launch them again # chmod +x /path/to/your/project/watcher.sh # crontab -e # * * * * * /path/to/your/project/watcher.sh # Schedules watcher to run every minute # Define program to run cmd1() { your_command_here & echo $! > /tmp/cmd1.pid } # If file not exists launch program (for the first time) if [ ! -f /tmp/cmd1.pid ] then cmd1; fi # Check if process with given ID (/tmp/cmd1.pid) is running # If not, launch again if [ ! -d /proc/$(</tmp/cmd1.pid) ] then cmd1; # launch script now=`date`; # Store current date echo "$now - relaunching" >> /path/to/your/project/watcher.log # Log date of re-run fi