Add documentation files
This commit is contained in:
1 parent
fb4cdeb0cd
commit
1d45442fed
7 files changed
+295
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# SystemD
|
||||
|
||||
There are many ways to create a systemd compatible service file. This guide is tailored to be "production ready".
|
||||
|
||||
## Guide
|
||||
|
||||
1. Create a new user named drawit: `sudo useradd --system --create-home --shell /usr/sbin/nologin drawit`
|
||||
2. Create env directory: `sudo mkdir -p /etc/drawit`
|
||||
3. Copy `.env.example` here: `sudo cp .env.example /etc/drawit/drawit.env`
|
||||
4. Change directory to /opt: `cd /opt`
|
||||
5. Follow instructions to [clone the repo](BUILDING.md#guide). Skip steps 4, 5, and 8.
|
||||
6. Change permissions to drawit: `sudo chown -R drawit:drawit /opt/drawit /etc/drawit`
|
||||
7. Create a new service file: `sudo nano /etc/systemd/system/drawit.service`
|
||||
8. Paste in these contents:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=DrawIt
|
||||
After=syslog.target network.target remote-fs.target nss-lookup.target network-online.target
|
||||
Wants=network-online.target
|
||||
Requires=nginx.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=drawit
|
||||
Group=drawit
|
||||
WorkingDirectory=/opt/drawit
|
||||
Environment=NODE_ENV=production
|
||||
Environment=PORT=3000
|
||||
EnvironmentFile=/etc/drawit/drawit.env
|
||||
ExecStart=/usr/bin/npm run start
|
||||
RestartSec=5
|
||||
KillSignal=SIGINT
|
||||
TimeoutStopSec=30
|
||||
SyslogIdentifier=drawit
|
||||
TimeoutSec=30
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
9. If you want to use a different port, make sure to change it e.g. `Environment=PORT=10000`
|
||||
10. OPTIONALLY reload system daemon: `sudo systemctl daemon-reload`
|
||||
11. Enable and start the service: `sudo systemctl enable --now drawit.service`
|
||||
12. Check the service for errors: `sudo systemctl status drawit.service`
|
||||
|
||||
You should now be running your very own DrawIt instance!
|
||||
|
||||
## Additional reading
|
||||
|
||||
After you know *it works!*, you should set up a [reverse proxy](REVERSE_PROXIES.md).
|
||||
Reference in new issue
Block a user