File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ SERVICE_NAME := sw
2+
3+ define SERVICE_FILE
4+ [Unit]
5+ Description=Showcase Website
6+ After=network.target
7+
8+ [Service]
9+ ExecStart=$(shell which bun) run start
10+ WorkingDirectory=$(shell pwd)
11+ Restart=always
12+ RestartSec=5
13+ User=$(shell whoami)
14+
15+ [Install]
16+ WantedBy=multi-user.target
17+ endef
18+
19+ export SERVICE_FILE
20+
21+ .PHONY : help init update logs
22+
23+ help :
24+ @echo " This is a production only tool. Please use bun directly in development."
25+ @echo " "
26+ @echo " Run 'sudo make init' once, and then every time you want to update the website, run 'sudo make update'."
27+ @echo " "
28+ @echo " Rules:"
29+ @echo " - init: creates the service"
30+ @echo " - restart: restart website wthout pulling latest version"
31+ @echo " - update: updates and restarts"
32+ @echo " - logs: opens the logs"
33+ @echo " - help: displays this message"
34+
35+ init :
36+ echo " $$ SERVICE_FILE" | sudo tee /etc/systemd/system/$(SERVICE_NAME ) .service
37+ sudo systemctl daemon-reload
38+ sudo systemctl enable $(SERVICE_NAME )
39+
40+ update :
41+ git fetch origin
42+ git reset --hard origin/main
43+ git pull --force origin main
44+ sudo systemctl stop $(SERVICE_NAME )
45+ bun i
46+ bun run build
47+ sudo systemctl start $(SERVICE_NAME )
48+
49+ restart :
50+ sudo systemctl restart $(SERVICE_NAME )
51+
52+ logs :
53+ sudo journalctl -xeu $(SERVICE_NAME )
You can’t perform that action at this time.
0 commit comments