add systemd user unit so the dev server starts at boot
This commit is contained in:
parent
bc738541cf
commit
174212750b
3 changed files with 78 additions and 3 deletions
44
deploy/dvorakmortonxd-dev.service
Normal file
44
deploy/dvorakmortonxd-dev.service
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# User systemd service for the dvorakmortonxd.dev dev server.
|
||||
#
|
||||
# Install (no root needed, runs as the current user):
|
||||
#
|
||||
# mkdir -p ~/.config/systemd/user
|
||||
# cp deploy/dvorakmortonxd-dev.service ~/.config/systemd/user/
|
||||
# systemctl --user daemon-reload
|
||||
# systemctl --user enable --now dvorakmortonxd-dev.service
|
||||
# loginctl enable-linger "$USER" # once: start at boot without logging in
|
||||
#
|
||||
# Manage:
|
||||
# systemctl --user status dvorakmortonxd-dev
|
||||
# systemctl --user restart dvorakmortonxd-dev
|
||||
# systemctl --user stop dvorakmortonxd-dev
|
||||
# journalctl --user -u dvorakmortonxd-dev -f
|
||||
#
|
||||
# It shares .next/dev/lock with a manual `npm run dev`, so stop the service
|
||||
# before starting one by hand.
|
||||
|
||||
[Unit]
|
||||
Description=dvorakmortonxd.dev dev server (custom Next.js dev wrapper)
|
||||
Documentation=file:///home/martin/dvorakmortonxd.dev/README.md
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/home/martin/dvorakmortonxd.dev
|
||||
# Bind all interfaces so the Cloudflare tunnel host can reach :3000. Pin
|
||||
# HOSTNAME explicitly: the dev server reads process.env.HOSTNAME and would
|
||||
# otherwise try to bind to whatever systemd/the shell exported.
|
||||
Environment=HOSTNAME=0.0.0.0
|
||||
Environment=PORT=3000
|
||||
# A reboot can leave a stale dev lock behind; clear it before starting.
|
||||
ExecStartPre=/bin/rm -f /home/martin/dvorakmortonxd.dev/.next/dev/lock
|
||||
ExecStart=/bin/node /home/martin/dvorakmortonxd.dev/scripts/dev-server.mjs
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
# Give Next.js a moment to shut down cleanly.
|
||||
TimeoutStopSec=15
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
Loading…
Add table
Add a link
Reference in a new issue