mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
service: Implement action for systemd try-restart
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
0f2e145863
commit
d8ddf6abff
@ -15,16 +15,15 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Wrapper to list and handle system services
|
Wrapper to list and handle system services
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from importlib import import_module
|
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
from plinth import action_utils, cfg
|
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, 'enable', 'enable a service')
|
||||||
add_service_action(subparsers, 'disable', 'disable a service')
|
add_service_action(subparsers, 'disable', 'disable a service')
|
||||||
add_service_action(subparsers, 'restart', 'restart 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, 'reload', 'reload a service')
|
||||||
add_service_action(subparsers, 'is-running', 'status of a service')
|
add_service_action(subparsers, 'is-running', 'status of a service')
|
||||||
add_service_action(subparsers, 'is-enabled', 'status 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)
|
action_utils.service_restart(arguments.service)
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_try_restart(arguments):
|
||||||
|
action_utils.service_try_restart(arguments.service)
|
||||||
|
|
||||||
|
|
||||||
def subcommand_reload(arguments):
|
def subcommand_reload(arguments):
|
||||||
action_utils.service_reload(arguments.service)
|
action_utils.service_reload(arguments.service)
|
||||||
|
|
||||||
@ -113,7 +118,7 @@ def subcommand_list(_):
|
|||||||
if unit.endswith(suffix):
|
if unit.endswith(suffix):
|
||||||
name = unit[:-len(suffix)]
|
name = unit[:-len(suffix)]
|
||||||
if name in services:
|
if name in services:
|
||||||
services[name] = {'running': (sub=='running')}
|
services[name] = {'running': (sub == 'running')}
|
||||||
|
|
||||||
print(json.dumps(services))
|
print(json.dumps(services))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user