From 95827438c5c0e85393b82cf2d9253380b5d49f88 Mon Sep 17 00:00:00 2001 From: irina11y <38069993+irina11y@users.noreply.github.com> Date: Thu, 6 Sep 2018 14:00:09 +0200 Subject: [PATCH] Add option '--need-lock' to 'yunohost service add' (#530) * [enh] Add option '--need-lock' * corection typo * correction merge --- data/actionsmap/yunohost.yml | 4 ++++ src/yunohost/service.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 6e2743015..140f8bc6a 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1136,6 +1136,10 @@ service: full: --runlevel help: Runlevel priority of the service type: int + -n: + full: --need_lock + help: Use this option to prevent deadlocks if the service does invoke yunohost commands. + action: store_true -d: full: --description help: Description of the service diff --git a/src/yunohost/service.py b/src/yunohost/service.py index dbdaa1cdf..5b7680a80 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -50,7 +50,7 @@ MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock" logger = log.getActionLogger('yunohost.service') -def service_add(name, status=None, log=None, runlevel=None, description=None): +def service_add(name, status=None, log=None, runlevel=None, need_lock=False, description=None): """ Add a custom service @@ -59,8 +59,8 @@ def service_add(name, status=None, log=None, runlevel=None, description=None): status -- Custom status command log -- Absolute path to log file to display runlevel -- Runlevel priority of the service + need_lock -- Use this option to prevent deadlocks if the service does invoke yunohost commands. description -- description of the service - """ services = _get_services() @@ -75,6 +75,9 @@ def service_add(name, status=None, log=None, runlevel=None, description=None): if runlevel is not None: services[name]['runlevel'] = runlevel + if need_lock: + services[name]['need_lock'] = True + if description is not None: services[name]['description'] = description