Commit d8ddf6ab authored by Sunil Mohan Adapa's avatar Sunil Mohan Adapa Committed by Joseph Nuthalapati

service: Implement action for systemd try-restart

Signed-off-by: Sunil Mohan Adapa's avatarSunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <njoseph@thoughtworks.com>
parent 0f2e1458
......@@ -15,16 +15,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Wrapper to list and handle system services
"""
import argparse
from importlib import import_module
import os
import json
import os
import subprocess
from importlib import import_module
from plinth import action_utils, cfg
......@@ -47,6 +46,8 @@ def parse_arguments():
add_service_action(subparsers, 'enable', 'enable a service')
add_service_action(subparsers, 'disable', 'disable a service')
add_service_action(subparsers, 'restart', 'restart a service')
add_service_action(subparsers, 'try-restart',
'restart a service if running')
add_service_action(subparsers, 'reload', 'reload a service')
add_service_action(subparsers, 'is-running', 'status of a service')
add_service_action(subparsers, 'is-enabled', 'status a service')
......@@ -78,6 +79,10 @@ def subcommand_restart(arguments):
action_utils.service_restart(arguments.service)
def subcommand_try_restart(arguments):
action_utils.service_try_restart(arguments.service)
def subcommand_reload(arguments):
action_utils.service_reload(arguments.service)
......@@ -113,7 +118,7 @@ def subcommand_list(_):
if unit.endswith(suffix):
name = unit[:-len(suffix)]
if name in services:
services[name] = {'running': (sub=='running')}
services[name] = {'running': (sub == 'running')}
print(json.dumps(services))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment