Skip to content

Commit

Permalink
refactor: move job running out of elastic-rebuild-all
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontalvo3 committed Jan 12, 2024
1 parent 76052b2 commit ec0e9fc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/roles/mediawiki/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
with_items:
- elastic-rebuild-all.sh
- smw-rebuild-all.sh
- run-all-jobs-now.sh
- refresh-links.sh

- name: Ensure data rebuilding logs directories exist
Expand Down
29 changes: 0 additions & 29 deletions src/roles/mediawiki/templates/elastic-rebuild-all.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -137,32 +137,3 @@ for d in $do_wikis; do
# Do ^ for each wiki, since the indexing will take a while

done

#
# FOURTH wiki loop: run all jobs for all wikis
#
for d in $do_wikis; do

if [ -z "$1" ]; then
wiki_id=${d%/}
else
wiki_id="$d"
fi

if [ ! -d "$wiki_dir/$wiki_id" ]; then
echo "\"$wiki_id\" not a valid wiki ID"
continue
fi

# Run all the jobs for this wiki
maxjobs=1000
while [ $(WIKI="$wiki_id" php /opt/htdocs/mediawiki/maintenance/showJobs.php) -gt 0 ]; do
WIKI="$wiki_id" php /opt/htdocs/mediawiki/maintenance/runJobs.php --maxjobs="$maxjobs"
echo
echo "Up to 1000 jobs complete. Pausing for 5 seconds."
echo
sleep 5
done;

done

46 changes: 46 additions & 0 deletions src/roles/mediawiki/templates/run-all-jobs-now.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

echo "Starting rebuilding search indexes as $(whoami)"

if [ -z "$1" ]; then
do_wikis="*/"
else
do_wikis="$1"
fi

wiki_dir="/opt/htdocs/wikis"

cd "$wiki_dir"

#
# FOURTH wiki loop: run all jobs for all wikis
#
for d in $do_wikis; do

if [ -z "$1" ]; then
wiki_id=${d%/}
else
wiki_id="$d"
fi

if [ ! -d "$wiki_dir/$wiki_id" ]; then
echo "\"$wiki_id\" not a valid wiki ID"
continue
fi

echo
echo "Running all jobs for ${wiki_id}"
echo


# Run all the jobs for this wiki
maxjobs=1000
while [ $(WIKI="$wiki_id" php /opt/htdocs/mediawiki/maintenance/showJobs.php) -gt 0 ]; do
WIKI="$wiki_id" php /opt/htdocs/mediawiki/maintenance/runJobs.php --maxjobs="$maxjobs"
echo
echo "Up to 1000 jobs complete. Pausing for 5 seconds."
echo
sleep 5
done;

done

0 comments on commit ec0e9fc

Please sign in to comment.