Skip to content

Commit 4e1df13

Browse files
authored
Merge pull request #89 from tim-moody/io-priority-18-9-25
Add priority to long running jobs
2 parents f21d46c + 2875ecc commit 4e1df13

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

iiab-admin.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
# doc_root: /library/www/html inherited from iiab
2222
adm_cons_force_ssl: False
2323
iiab_home_url: /home
24-
25-
24+
# these belong somewhere else, but this makes them overrideable by iiab local vars
25+
cmdsrv_lower_job_priority_flag: "true" # json requires true, not True
26+
cmdsrv_lower_job_priority_str: "/usr/bin/nice -n19 /usr/bin/ionice -c2 -n7 "
27+
2628
vars_files:
2729
- "{{ iiab_repo }}/vars/default_vars.yml"
2830
- "{{ iiab_repo }}/vars/{{ ansible_local.local_facts.os_ver }}.yml"

roles/cmdsrv/files/iiab-cmdsrv

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ cmdsrv_no_workers = 5
6565
cmdsrv_job_poll_sleep_interval = 1
6666
cmdsrv_max_concurrent_jobs = 7
6767

68+
cmdsrv_lower_job_priority_flag = None
69+
cmdsrv_lower_job_priority_str= None
70+
6871
# Derived Variables
6972
cmdsrv_dbpath = None
7073

@@ -498,10 +501,15 @@ def start_job(job_id, job_info, status='STARTED'):
498501
global running_job_count
499502
global ansible_running_flag
500503
global prereq_jobs
504+
global cmdsrv_lower_job_priority_flag
505+
global cmdsrv_lower_job_priority_str
501506

502507
job_info['output_file'] = '/tmp/job-' + str(job_id)
503508
job_info['file'] = open(job_info['output_file'], 'w')
504-
args = shlex.split(job_info['job_command'])
509+
if cmdsrv_lower_job_priority_flag:
510+
args = shlex.split(cmdsrv_lower_job_priority_str + job_info['job_command'])
511+
else:
512+
args = shlex.split(job_info['job_command'])
505513
job_info['subproc'] = subprocess.Popen(args, stdout=job_info['file'], stderr=subprocess.STDOUT)
506514
job_info['job_pid'] = job_info['subproc'].pid
507515
job_info['status'] = status
@@ -2425,6 +2433,8 @@ def app_config():
24252433
global cmdsrv_no_workers
24262434
global cmdsrv_job_poll_sleep_interval
24272435
global cmdsrv_max_concurrent_jobs
2436+
global cmdsrv_lower_job_priority_flag
2437+
global cmdsrv_lower_job_priority_str
24282438
global cmdsrv_pid_file
24292439
global cmdsrv_ready_file
24302440
global kiwix_catalog_file
@@ -2467,6 +2477,8 @@ def app_config():
24672477
cmdsrv_no_workers = conf['cmdsrv_no_workers']
24682478
cmdsrv_job_poll_sleep_interval = conf['cmdsrv_job_poll_sleep_interval']
24692479
cmdsrv_max_concurrent_jobs = conf['cmdsrv_max_concurrent_jobs']
2480+
cmdsrv_lower_job_priority_flag = conf['cmdsrv_lower_job_priority_flag']
2481+
cmdsrv_lower_job_priority_str = conf['cmdsrv_lower_job_priority_str']
24702482
cmdsrv_pid_file = conf['cmdsrv_pid_file']
24712483
cmdsrv_ready_file = conf['cmdsrv_ready_file']
24722484
kiwix_catalog_file = conf['kiwix_catalog_file']

roles/cmdsrv/templates/cmdsrv.conf.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"cmdsrv_max_concurrent_jobs" : 7,
1414
"cmdsrv_pid_file" : "{{ cmdsrv_pid_file }}",
1515
"cmdsrv_ready_file" : "{{ cmdsrv_ready_file }}",
16+
"cmdsrv_lower_job_priority_flag" : {{ cmdsrv_lower_job_priority_flag }},
17+
"cmdsrv_lower_job_priority_str" : "{{ cmdsrv_lower_job_priority_str }}",
1618
"kiwix_catalog_file" : "{{ iiab_config_dir }}/kiwix_catalog.json",
1719
"content_base" : "/library",
1820
"zim_dir" : "/library/zims/",

0 commit comments

Comments
 (0)