mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Start JupyterHub / CHP when system starts
This commit is contained in:
@@ -46,6 +46,10 @@ def ensure_jupyterhub_service(prefix):
|
|||||||
# If JupyterHub is running, we want to restart it.
|
# If JupyterHub is running, we want to restart it.
|
||||||
systemd.restart_service('jupyterhub')
|
systemd.restart_service('jupyterhub')
|
||||||
|
|
||||||
|
# Mark JupyterHub & CHP to start at boot ime
|
||||||
|
systemd.enable_service('jupyterhub')
|
||||||
|
systemd.enable_service('configurable-http-proxy')
|
||||||
|
|
||||||
|
|
||||||
def ensure_jupyterhub_package(prefix):
|
def ensure_jupyterhub_package(prefix):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -23,3 +23,7 @@ ExecStart={install_prefix}/hub/bin/configurable-http-proxy \
|
|||||||
--api-ip 127.0.0.1 \
|
--api-ip 127.0.0.1 \
|
||||||
--api-port 15002 \
|
--api-port 15002 \
|
||||||
--error-target http://127.0.0.1:15001/hub/error
|
--error-target http://127.0.0.1:15001/hub/error
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
# Start service when system boots
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|||||||
@@ -20,3 +20,7 @@ ProtectKernelModules=yes
|
|||||||
EnvironmentFile={install_prefix}/configurable-http-proxy.secret
|
EnvironmentFile={install_prefix}/configurable-http-proxy.secret
|
||||||
Environment=TLJH_INSTALL_PREFIX={install_prefix}
|
Environment=TLJH_INSTALL_PREFIX={install_prefix}
|
||||||
ExecStart={python_interpreter_path} -m jupyterhub.app -f {jupyterhub_config_path}
|
ExecStart={python_interpreter_path} -m jupyterhub.app -f {jupyterhub_config_path}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
# Start service when system boots
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|||||||
@@ -57,3 +57,16 @@ def restart_service(name):
|
|||||||
'restart',
|
'restart',
|
||||||
name
|
name
|
||||||
], check=True)
|
], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def enable_service(name):
|
||||||
|
"""
|
||||||
|
Enable a service with given name.
|
||||||
|
|
||||||
|
This most likely makes the service start on bootup
|
||||||
|
"""
|
||||||
|
subprocess.run([
|
||||||
|
'systemctl',
|
||||||
|
'enable',
|
||||||
|
name
|
||||||
|
], check=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user