From 5aa00598056c396aff1c49a43470ece793f9142b Mon Sep 17 00:00:00 2001 From: Harry-zklcdc Date: Wed, 15 Jan 2025 15:51:18 +0800 Subject: [PATCH] =?UTF-8?q?[Feat]=20=E2=9C=A8=20Add=20Code-Server=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...h-1.10.2_cuda-11.1_python-3.9_ubuntu-20.04 | 13 ++- ...-1.13.1_cuda-11.7_python-3.10_ubuntu-22.04 | 13 ++- ...ch-1.8.1_cuda-11.1_python-3.8_ubuntu-20.04 | 13 ++- ...h-2.0.1_cuda-11.8_python-3.10_ubuntu-22.04 | 13 ++- ...h-2.1.2_cuda-12.1_python-3.10_ubuntu-22.04 | 13 ++- ...h-2.3.1_cuda-12.1_python-3.11_ubuntu-22.04 | 13 ++- ...h-2.4.0_cuda-12.1_python-3.12_ubuntu-22.04 | 13 ++- Dockerfile.ubuntu-22.04 | 11 ++- Ubuntu-22.04/entrypoint.sh | 1 + code-server | 94 +++++++++++++++++++ code-server.yaml | 4 + 11 files changed, 178 insertions(+), 23 deletions(-) create mode 100755 code-server create mode 100644 code-server.yaml diff --git a/Dockerfile.pytorch-1.10.2_cuda-11.1_python-3.9_ubuntu-20.04 b/Dockerfile.pytorch-1.10.2_cuda-11.1_python-3.9_ubuntu-20.04 index 41e3f95..396b279 100644 --- a/Dockerfile.pytorch-1.10.2_cuda-11.1_python-3.9_ubuntu-20.04 +++ b/Dockerfile.pytorch-1.10.2_cuda-11.1_python-3.9_ubuntu-20.04 @@ -67,6 +67,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -96,10 +102,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -113,4 +120,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.pytorch-1.13.1_cuda-11.7_python-3.10_ubuntu-22.04 b/Dockerfile.pytorch-1.13.1_cuda-11.7_python-3.10_ubuntu-22.04 index b71f183..90bf54c 100644 --- a/Dockerfile.pytorch-1.13.1_cuda-11.7_python-3.10_ubuntu-22.04 +++ b/Dockerfile.pytorch-1.13.1_cuda-11.7_python-3.10_ubuntu-22.04 @@ -67,6 +67,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -96,10 +102,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -113,4 +120,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.pytorch-1.8.1_cuda-11.1_python-3.8_ubuntu-20.04 b/Dockerfile.pytorch-1.8.1_cuda-11.1_python-3.8_ubuntu-20.04 index 524c63a..8c64fff 100644 --- a/Dockerfile.pytorch-1.8.1_cuda-11.1_python-3.8_ubuntu-20.04 +++ b/Dockerfile.pytorch-1.8.1_cuda-11.1_python-3.8_ubuntu-20.04 @@ -67,6 +67,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -96,10 +102,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -113,4 +120,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.pytorch-2.0.1_cuda-11.8_python-3.10_ubuntu-22.04 b/Dockerfile.pytorch-2.0.1_cuda-11.8_python-3.10_ubuntu-22.04 index a805c5c..780fab8 100644 --- a/Dockerfile.pytorch-2.0.1_cuda-11.8_python-3.10_ubuntu-22.04 +++ b/Dockerfile.pytorch-2.0.1_cuda-11.8_python-3.10_ubuntu-22.04 @@ -67,6 +67,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -96,10 +102,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -113,4 +120,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.pytorch-2.1.2_cuda-12.1_python-3.10_ubuntu-22.04 b/Dockerfile.pytorch-2.1.2_cuda-12.1_python-3.10_ubuntu-22.04 index b44bd38..9ae7e16 100644 --- a/Dockerfile.pytorch-2.1.2_cuda-12.1_python-3.10_ubuntu-22.04 +++ b/Dockerfile.pytorch-2.1.2_cuda-12.1_python-3.10_ubuntu-22.04 @@ -68,6 +68,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -97,10 +103,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -114,4 +121,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.pytorch-2.3.1_cuda-12.1_python-3.11_ubuntu-22.04 b/Dockerfile.pytorch-2.3.1_cuda-12.1_python-3.11_ubuntu-22.04 index 44b5ed4..27f30ba 100644 --- a/Dockerfile.pytorch-2.3.1_cuda-12.1_python-3.11_ubuntu-22.04 +++ b/Dockerfile.pytorch-2.3.1_cuda-12.1_python-3.11_ubuntu-22.04 @@ -68,6 +68,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -97,10 +103,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -114,4 +121,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.pytorch-2.4.0_cuda-12.1_python-3.12_ubuntu-22.04 b/Dockerfile.pytorch-2.4.0_cuda-12.1_python-3.12_ubuntu-22.04 index c7754d6..ab243b4 100644 --- a/Dockerfile.pytorch-2.4.0_cuda-12.1_python-3.12_ubuntu-22.04 +++ b/Dockerfile.pytorch-2.4.0_cuda-12.1_python-3.12_ubuntu-22.04 @@ -67,6 +67,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -96,10 +102,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH"\nexport LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc @@ -113,4 +120,4 @@ COPY .condarc /root/.condarc RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ # 修改启动脚本 -RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh +RUN sed -i ':a;$!{N;ba}; s|\necho\n|\necho\nrm -r /var/lib/prometheus/metrics2/*\nulimit -n 64000\nservice ssh start\nservice jupyter start\nservice code-server start\nservice prometheus start\nservice prometheus-node-exporter start\nservice nvidia_gpu_exporter start\nservice grafana-server start|' /opt/nvidia/nvidia_entrypoint.sh diff --git a/Dockerfile.ubuntu-22.04 b/Dockerfile.ubuntu-22.04 index e211f0b..4ada800 100644 --- a/Dockerfile.ubuntu-22.04 +++ b/Dockerfile.ubuntu-22.04 @@ -58,6 +58,12 @@ RUN sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && # 创建 SSH 运行时目录 RUN mkdir -p /var/run/sshd +# 安装 code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh +COPY code-server.yaml /root/.config/code-server/config.yaml +COPY code-server /etc/init.d/code-server +RUN chmod +x /etc/init.d/code-server + # 安装 Prometheus Node-Exporter RUN apt-get update && apt-get install -y --no-install-recommends prometheus prometheus-node-exporter && \ apt-get clean && rm -r /var/lib/apt/lists/* @@ -87,10 +93,11 @@ RUN chown grafana:grafana /var/lib/grafana/grafana.db RUN apt-get clean || true && \ rm -r /var/lib/apt/lists/* || true && \ conda clean -y --all || true && \ - rm -r ~/.cache/pip/* || true + rm -r ~/.cache/pip/* || true && \ + rm -r ~/.cache/code-server/* || true # 暴露 Jupyter Notebook 的默认端口 8888 和 SSH 默认端口 22 -EXPOSE 8888 22 3000 +EXPOSE 8888 22 3000 8080 RUN echo -e 'export LANG="C.UTF-8"\n/etc/update-motd.d/10-help-text' >> /root/.bashrc diff --git a/Ubuntu-22.04/entrypoint.sh b/Ubuntu-22.04/entrypoint.sh index f93034d..db21715 100644 --- a/Ubuntu-22.04/entrypoint.sh +++ b/Ubuntu-22.04/entrypoint.sh @@ -10,6 +10,7 @@ service prometheus start service prometheus-node-exporter start service nvidia_gpu_exporter start service grafana-server start +service code-server start tail -f /dev/null diff --git a/code-server b/code-server new file mode 100755 index 0000000..6004d8a --- /dev/null +++ b/code-server @@ -0,0 +1,94 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: jupyter +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Code Server service +# Description: Start and stop the Code Server server +### END INIT INFO + +set -e + +DESC="Code Server service" +NAME=code-server +DAEMON=/usr/bin/code-server +DAEMON_OPTS="" +PIDFILE=/run/code-server.pid +LOGFILE=/var/log/code-server.log +WORKDIR=/root/ +PATH=/root/miniconda3/bin:/root/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin + +. /lib/lsb/init-functions + +start_jupyter() { + cd $WORKDIR + nohup $DAEMON $DAEMON_OPTS >> $LOGFILE 2>&1 & + echo $! > $PIDFILE +} + +do_start() { + log_daemon_msg "Starting $DESC" "$NAME" + if [ -f $PIDFILE ]; then + PID=$(cat $PIDFILE) + if ps -p $PID > /dev/null && grep -q "$DAEMON" /proc/$PID/cmdline; then + log_progress_msg "Code Server is already running." + else + start_jupyter + log_end_msg 0 + fi + else + start_jupyter + log_end_msg 0 + fi +} + +do_stop() { + log_daemon_msg "Stopping $DESC" "$NAME" + if [ -f $PIDFILE ]; then + PID=$(cat $PIDFILE) + if ps -p $PID > /dev/null && grep -q "$DAEMON" /proc/$PID/cmdline; then + kill -9 $PID + rm -f $PIDFILE + log_end_msg 0 + else + log_end_msg 0 + fi + # else + # log_progress_msg "Code Server is not running." + # log_end_msg 1 + fi +} + +do_restart() { + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + sleep 2 + do_start +} + +do_status() { + status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? +} + +case "$1" in + start) + do_start + ;; + stop) + do_stop + ;; + restart|force-reload) + do_restart + ;; + status) + do_status + ;; + *) + echo "Usage: $0 {start|stop|restart|force-reload|status}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/code-server.yaml b/code-server.yaml new file mode 100644 index 0000000..be6db8a --- /dev/null +++ b/code-server.yaml @@ -0,0 +1,4 @@ +bind-addr: 0.0.0.0:8080 +auth: password +password: CHANGETHIS +cert: false \ No newline at end of file