Last active
August 21, 2024 18:03
-
-
Save nicosomb/976c7888d653b338fcab1787fa6c75ef to your computer and use it in GitHub Desktop.
Script to relaunch asynchronous redis workers for wallabag (for pocket / instapaper / readability / pinboard imports)
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 bash | |
nbWorkers=10 | |
wallabag_path='/var/www/app.wallabag.it' | |
workers[0]='pocket' | |
workers[1]='instapaper' | |
workers[2]='readability' | |
workers[3]='wallabag_v1' | |
workers[4]='wallabag_v2' | |
workers[5]='firefox' | |
workers[6]='chrome' | |
workers[7]='pinboard' | |
for K in "${!workers[@]}" | |
do | |
currentWorker=${workers[$K]} | |
echo '----------------------------------------------------------' | |
echo '---- Start ['$(date +%Y-%m-%d:%H:%M:%S)']: '$currentWorker | |
nbCurrentWorker=$(ps -ef | grep 'wallabag:import:redis-worker -e=prod '$currentWorker| grep -Ev "grep" | wc -l) | |
difference=$(($nbWorkers-$nbCurrentWorker)) | |
echo '----' $difference 'workers to start' | |
if [ "$difference" -ge 0 ] | |
then | |
for (( i = 1; i <= $difference; i++ )) | |
do | |
echo '---- Starting worker #'$i | |
cd $wallabag_path | |
commandToRun='php bin/console wallabag:import:redis-worker -e=prod '$currentWorker' -vv' | |
$commandToRun >> $wallabag_path'/var/logs/redis-'$currentWorker'.log' & | |
done | |
fi | |
echo '---- End ['$(date +%Y-%m-%d:%H:%M:%S)']: '$currentWorker | |
echo '----------------------------------------------------------' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment