Skip to content

Commit bf6a90e

Browse files
committed
enh: include DCOR worker configuration
1 parent b012a55 commit bf6a90e

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.10.2
2+
- enh: include DCOR worker configuration
23
- update compatible versions
34
0.10.1
45
- fix: add ckanext.dc_serve.tmp_dir, a temporary data location for

dcor_control/inspect/config_supervisord.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pkg_resources import resource_filename
12
import subprocess as sp
23

34
import click
@@ -8,23 +9,22 @@
89

910
def check_supervisord(autocorrect):
1011
"""Check whether the separate dcor worker files exist"""
12+
path_worker = resource_filename(
13+
"dcor_control.resources.config",
14+
"etc_supervisor_conf.d_ckan-worker-dcor.conf")
15+
template = path_worker.read_text()
16+
1117
svd_path = get_supervisord_worker_config_path()
1218
for worker in ["long", "normal", "short"]:
13-
wpath = svd_path.with_name("ckan-worker-dcor-{}.conf".format(worker))
19+
wpath = svd_path.with_name(f"ckan-worker-dcor-{worker}.conf")
1420
if not wpath.exists():
1521
if autocorrect:
1622
wcr = True
17-
print("Creating '{}'.".format(wpath))
23+
print(f"Creating '{wpath}'.")
1824
else:
19-
wcr = ask("Supervisord entry 'dcor-{}' missing".format(worker))
25+
wcr = ask(f"Supervisord entry 'dcor-{worker}' missing")
2026
if wcr:
21-
data = svd_path.read_text()
22-
data = data.replace(
23-
"[program:ckan-worker]",
24-
"[program:ckan-ckan-worker-dcor-{}]".format(worker))
25-
data = data.replace(
26-
"/ckan.ini jobs worker",
27-
"/ckan.ini jobs worker dcor-{}".format(worker))
27+
data = template.replace("{{QUEUE}}", f"dcor-{worker}")
2828
wpath.write_text(data)
2929

3030

dcor_control/resources/config/__init__.py

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[program:ckan-worker-{{QUEUE}}]
2+
3+
environment=CKAN_INI=/etc/ckan/default/ckan.ini,PYTHONUNBUFFERED=1
4+
command=/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini jobs worker {{QUEUE}}
5+
6+
user=www-data
7+
8+
; Start just a single worker. Increase this number if you have many or
9+
; particularly long running background jobs.
10+
numprocs=1
11+
process_name=%(program_name)s-%(process_num)02d
12+
13+
; Log files
14+
stdout_logfile=/var/log/ckan/ckan-worker-{{QUEUE}}.stdout.log
15+
stderr_logfile=/var/log/ckan/ckan-worker-{{QUEUE}}.stderr.log
16+
17+
; Make sure that the worker is started on system start and automatically
18+
; restarted if it crashes unexpectedly.
19+
autostart=true
20+
autorestart=true
21+
22+
; Number of seconds the process has to run before it is considered to have
23+
; started successfully.
24+
startsecs=10
25+
26+
; Need to wait for currently executing tasks to finish at shutdown.
27+
; Increase this if you have very long running tasks.
28+
stopwaitsecs=60

0 commit comments

Comments
 (0)