From 0141ded35db94a1d84941dd433999e95e2a7b17d Mon Sep 17 00:00:00 2001 From: Ayane Satomi Date: Tue, 17 Sep 2019 04:05:25 +0800 Subject: [PATCH] [doc/quickstart] add init docs (#981) Add init docs so people have an idea what to do when starting up a service. Resolves GH-947 --- doc/quickstart.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/doc/quickstart.md b/doc/quickstart.md index b930c5c2..eb974692 100644 --- a/doc/quickstart.md +++ b/doc/quickstart.md @@ -55,3 +55,62 @@ server { ``` + +### Run automatically at startup + +In some cases you might need to run code-server automatically once the host starts. You may use your local init service to do so. + +#### Systemd + +```ini +[Unit] + +Description=VSCode in a browser + +After=network.target + +[Service] + +Type=simple + +ExecStart=/usr/bin/code-server $(pwd) + +WorkingDirectory=$HOME/projects + +ExecStop=/sbin/start-stop-daemon --stop -x /usr/bin/code-server + +Restart=on-failure + +User=1000 + +[Install] + +WantedBy=multi-user.target +``` + +#### OpenRC + +```sh +#!/sbin/openrc-run + +depend() { + after net-online + need net +} + +supervisor=supervise-daemon +name="code-server" +command="/opt/cdr/code-server" +command_args="" + +pidfile="/var/run/cdr.pid" +respawn_delay=5 + +set -o allexport +if [ -f /etc/environment ]; then source /etc/environment; fi +set +o allexport +``` + +#### Kubernetes/Docker + +Make sure you set your restart policy to always - this will ensure your container starts as the daemon starts.