Created
September 2, 2018 06:48
-
-
Save Ahed91/cd4bc3f0c2d019606ecc7253c887d681 to your computer and use it in GitHub Desktop.
my setup Laravel queue worker
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
[program:laravelQueueOnce1] | |
command=bash -c 'sleep 5 && php artisan queue:work --once --queue=blocked' | |
directory=/home/ahed/project/laravel/ | |
autostart=true | |
autorestart=true | |
redirect_stderr=true | |
user=ahed ; should use www-data | |
stdout_logfile=syslog | |
stderr_logfile=syslog | |
autostart=true | |
autorestart=true | |
startsecs=1 | |
startretries=9999999999 |
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
[program:laravelQueueOnce2] | |
command=bash -c 'sleep 5 && php artisan queue:work --once --queue=blocked' | |
directory=/home/ahed/project/laravel/ | |
autostart=true | |
autorestart=true | |
redirect_stderr=true | |
user=ahed ; should use www-data | |
stdout_logfile=syslog | |
stderr_logfile=syslog | |
autostart=true | |
autorestart=true | |
startsecs=1 | |
startretries=9999999999 |
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
#!/usr/bin/env php | |
<?php | |
/* $content = file_get_contents('./syslog_small'); */ | |
/* $content_length = mb_strlen($content); */ | |
$var_names = [ | |
/* 'laravelQueue', */ | |
/* 'laravelQueue2', */ | |
'laravelQueueOnce1', | |
'laravelQueueOnce2', | |
/* 'laravelQueueOnce3', */ | |
/* 'laravelQueueOnce4', */ | |
/* 'laravelQueueOnce5', */ | |
/* 'laravelTwitterWatch', */ | |
/* 'laravelTwitterWatch2', */ | |
]; | |
foreach($var_names as $var_name) { | |
$line_counts = intval(explode(' ', shell_exec("wc -l /var/log/syslog"))[0]); | |
$line_number = intval(trim(shell_exec("cat /var/log/syslog | grep -n '$var_name ' | tail -n1 | cut -d: -f1"))); | |
if ($line_counts - $line_number > 500) { | |
shell_exec("logger restart $var_name manually"); | |
shell_exec("sudo supervisorctl restart $var_name"); | |
} | |
} |
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
# use this command to open root cronttab | |
# $ sudo crontab -e | |
# | |
# | |
*/10 * * * /path/to/restart_supervisor.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment