Skip to content

Commit 0141ded

Browse files
sr229code-asher
authored andcommitted
[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
1 parent bb46e80 commit 0141ded

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

doc/quickstart.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,62 @@ server {
5555
5656
</VirtualHost>
5757
```
58+
59+
### Run automatically at startup
60+
61+
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.
62+
63+
#### Systemd
64+
65+
```ini
66+
[Unit]
67+
68+
Description=VSCode in a browser
69+
70+
After=network.target
71+
72+
[Service]
73+
74+
Type=simple
75+
76+
ExecStart=/usr/bin/code-server $(pwd)
77+
78+
WorkingDirectory=$HOME/projects
79+
80+
ExecStop=/sbin/start-stop-daemon --stop -x /usr/bin/code-server
81+
82+
Restart=on-failure
83+
84+
User=1000
85+
86+
[Install]
87+
88+
WantedBy=multi-user.target
89+
```
90+
91+
#### OpenRC
92+
93+
```sh
94+
#!/sbin/openrc-run
95+
96+
depend() {
97+
after net-online
98+
need net
99+
}
100+
101+
supervisor=supervise-daemon
102+
name="code-server"
103+
command="/opt/cdr/code-server"
104+
command_args=""
105+
106+
pidfile="/var/run/cdr.pid"
107+
respawn_delay=5
108+
109+
set -o allexport
110+
if [ -f /etc/environment ]; then source /etc/environment; fi
111+
set +o allexport
112+
```
113+
114+
#### Kubernetes/Docker
115+
116+
Make sure you set your restart policy to always - this will ensure your container starts as the daemon starts.

0 commit comments

Comments
 (0)