summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartinko2012-07-24 12:04:52 +0000
committermartinko2012-07-24 12:04:52 +0000
commitf7d9cdbb2849bd2e187e2d13eb37dbc8972197a2 (patch)
tree27046afcb48701e343e806fff1a252ed99a78092
parent5b54a246cf31cbe2a88154711a113ade73019859 (diff)
scripts/scriptmgr.py: added option for specifying service type
-t SVC, --type=SVC apply command to all jobs of this service type
-rwxr-xr-xscripts/scriptmgr.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/scripts/scriptmgr.py b/scripts/scriptmgr.py
index 26317036..58e60ec9 100755
--- a/scripts/scriptmgr.py
+++ b/scripts/scriptmgr.py
@@ -53,11 +53,11 @@ import skytools
command_usage = """
%prog [options] INI CMD [subcmd args]
-commands:
- start [-a | jobname ..] start a job
- stop [-a | jobname ..] stop a job
- restart [-a | jobname ..] restart job(s)
- reload [-a | jobname ..] send reload signal
+Commands:
+ start [-a | -t=service | jobname ...] start job(s)
+ stop [-a | -t=service | jobname ...] stop job(s)
+ restart [-a | -t=service | jobname ...] restart job(s)
+ reload [-a | -t=service | jobname ...] send reload signal
status
"""
@@ -78,6 +78,7 @@ class ScriptMgr(skytools.DBScript):
def init_optparse(self, p = None):
p = skytools.DBScript.init_optparse(self, p)
p.add_option("-a", "--all", action="store_true", help="apply command to all jobs")
+ p.add_option("-t", "--type", action="store", metavar="SVC", help="apply command to all jobs of this service type")
p.add_option("-w", "--wait", action="store_true", help="wait for job(s) after signaling")
p.set_usage(command_usage.strip())
return p
@@ -100,7 +101,7 @@ class ScriptMgr(skytools.DBScript):
'service': svc_name,
'script': cf.getfile('script', defscript),
'cwd': cf.getfile('cwd'),
- 'disabled': cf.getboolean('disabled', 0),
+ 'disabled': disabled,
'args': cf.get('args', ''),
}
self.svc_list.append(svc)
@@ -153,7 +154,7 @@ class ScriptMgr(skytools.DBScript):
for job in self.job_list:
os.chdir(job['cwd'])
cf = skytools.Config(job['service'], job['config'])
- pidfile = cf.getfile('pidfile', '')
+ pidfile = job['pidfile']
name = job['job_name']
svc = job['service']
if job['disabled']:
@@ -262,6 +263,10 @@ class ScriptMgr(skytools.DBScript):
if len(jobs) == 0 and self.options.all:
for job in self.job_list:
jobs.append(job['job_name'])
+ if len(jobs) == 0 and self.options.type:
+ for job in self.job_list:
+ if job['service'] == self.options.type:
+ jobs.append(job['job_name'])
self.job_list.sort(job_sort_cmp)