Skip to content

Commit 9114307

Browse files
committed
Fix meza maint run_jobs
sudo meza maint run_jobs will run all jobs for all wikis. Meza produces a wrapper script on deploy which can be used to invoke MediaWiki's maintenance run.php runJobs for all defined wikis. You can also selectively pass a wiki ID to the command. Fixed the script invocation and also uses the declarative wiki approach.
1 parent 091cf90 commit 9114307

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

src/scripts/meza.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,36 +1247,57 @@ def meza_command_maint(argv):
12471247

12481248
def meza_command_maint_run_jobs(argv):
12491249
"""
1250-
Run maintenance jobs for available wikis.
1250+
Run maintenance jobs (mediawiki/maintenance/runJobs.php) for available wikis.
12511251
1252-
This function runs maintenance jobs for the available wikis in the `wikis_dir`.
1253-
It selects the first wiki found and executes the `runAllJobs.php` script using
1254-
the `php` command. If a specific wiki is provided as a command-line argument,
1252+
This function executes the meza `runAllJobs.php` script.
1253+
1254+
By default, it will run jobs for ALL wikis. The wiki id used is just to get
1255+
meza to run. If a specific wiki is provided as a command-line argument,
12551256
the function runs maintenance jobs only for that wiki.
12561257
1258+
Usage:
1259+
Run jobs for all wikis:
1260+
sudo meza maint run_jobs
1261+
1262+
Run jobs for a specific wiki (e.g., 'demo'):
1263+
sudo meza maint run_jobs -- demo
1264+
12571265
Args:
12581266
argv (list): List of command-line arguments.
12591267
12601268
Returns:
12611269
None
12621270
"""
1263-
# FIXME #711: THIS FUNCTION SHOULD STILL WORK ON MONOLITHS, BUT HAS NOT BE
1264-
# RE-TESTED SINCE MOVING TO ANSIBLE. FOR NON-MONOLITHS IT WILL
1265-
# NOT WORK AND NEEDS TO BE ANSIBLE-IZED.
1271+
# FIXME This has not been made to work on a distributed app-server setup.
12661272

1267-
wikis_dir = f"{install_dir}/htdocs/wikis"
1268-
wikis = os.listdir(wikis_dir)
1269-
for i in wikis:
1270-
if os.path.isdir(os.path.join(wikis_dir, i)):
1271-
anywiki = i
1272-
break
1273+
# Get wiki list from declarative configuration
1274+
anywiki = None
1275+
try:
1276+
with open(f"{install_dir}/.deploy-meza/wiki-config.php", 'r') as config_file:
1277+
# Parse PHP config file to extract wiki list
1278+
# This is a simple approach - a more robust solution would use a proper PHP parser
1279+
# The wiki-config.php file is created during deploy and contains the
1280+
# list of wikis as the only quoted strings, so the simple regex works.
1281+
content = config_file.read()
1282+
import re
1283+
matches = re.findall(r"'([^']+)',", content)
1284+
if matches:
1285+
anywiki = matches[0] # Use first configured wiki
1286+
except (FileNotFoundError, IndexError):
1287+
# Fallback to directory-based discovery (legacy)
1288+
wikis_dir = f"{install_dir}/htdocs/wikis"
1289+
wikis = os.listdir(wikis_dir)
1290+
for i in wikis:
1291+
if os.path.isdir(os.path.join(wikis_dir, i)):
1292+
anywiki = i
1293+
break
12731294

12741295
if not anywiki:
12751296
print("No wikis available to run jobs")
12761297
sys.exit(1)
12771298

12781299
shell_cmd = ["WIKI=" + anywiki, "php",
1279-
f"{install_dir}/meza/src/scripts/runAllJobs.php"]
1300+
f"{install_dir}/.deploy-meza/runAllJobs.php"]
12801301
if len(argv) > 0:
12811302
shell_cmd = shell_cmd + ["--wikis=" + argv[1]]
12821303
rc = meza_shell_exec(shell_cmd)

0 commit comments

Comments
 (0)