mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Removed chp service
This commit is contained in:
@@ -48,6 +48,17 @@ def start_service(name):
|
||||
], check=True)
|
||||
|
||||
|
||||
def stop_service(name):
|
||||
"""
|
||||
Start service with given name.
|
||||
"""
|
||||
subprocess.run([
|
||||
'systemctl',
|
||||
'stop',
|
||||
name
|
||||
], check=True)
|
||||
|
||||
|
||||
def restart_service(name):
|
||||
"""
|
||||
Restart service with given name.
|
||||
@@ -72,6 +83,19 @@ def enable_service(name):
|
||||
], check=True)
|
||||
|
||||
|
||||
def disable_service(name):
|
||||
"""
|
||||
Enable a service with given name.
|
||||
|
||||
This most likely makes the service start on bootup
|
||||
"""
|
||||
subprocess.run([
|
||||
'systemctl',
|
||||
'disable',
|
||||
name
|
||||
], check=True)
|
||||
|
||||
|
||||
def check_service_active(name):
|
||||
"""
|
||||
Check if a service is currently active (running)
|
||||
@@ -85,3 +109,17 @@ def check_service_active(name):
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
def check_service_enabled(name):
|
||||
"""
|
||||
Check if a service is enabled
|
||||
"""
|
||||
try:
|
||||
subprocess.run([
|
||||
'systemctl',
|
||||
'is-enabled',
|
||||
name
|
||||
], check=True)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user