aboutsummaryrefslogtreecommitdiff
path: root/docs/SystemdSocketActivation.md
blob: 22c65b8ad48d46cc9a536d541e70b6664845869f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Using Systemd socket based activation to start Compiler Explorer

This document gives a short overview of how to use Systemd to automatically start Compiler Explorer when the
web-interface is accessed.

You'll need to create two files in `/etc/systemd/system/`:

compiler-explorer.socket:

```
[Socket]
ListenStream=10240

[Install]
WantedBy=sockets.target
```

compiler-explorer.service:

```
[Service]
Type=simple
WorkingDirectory={{path_to_installation_directory}}/compiler-explorer
ExecStart=/usr/bin/node {{path_to_installation_directory}}/compiler-explorer/out/dist/app.js
TimeoutStartSec=60
TimeoutStopSec=60
User={{run_as_this_user}}
Group={{run_as_this_group}}
```

Replace the bracketed `{{}}` placeholders with your system specifics.

Once the two above files are created Systemd needs to be made aware of the changes:

```sh
sudo systemctl daemon-reload
```

Now all that remains is to enable and start the new service:

```sh
sudo systemctl enable compiler-explorer.socket
sudo systemctl start compiler-explorer.socket
```

If all goes well you can now open the web-interface.