Skip to content

Commit bc3e684

Browse files
committed
feat(deploy): add make rule to remove installed services
1 parent d014a00 commit bc3e684

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SERVICE_NAME := showcase-website
2+
SERVICE_FILE_PATH := /etc/systemd/system/$(SERVICE_NAME).service
23

3-
define SERVICE_FILE
4+
define SERVICE_FILE_CONTENT
45
[Unit]
56
Description=Showcase Website
67
After=network.target
@@ -16,24 +17,25 @@ User=$(shell whoami)
1617
WantedBy=multi-user.target
1718
endef
1819

19-
export SERVICE_FILE
20+
export SERVICE_FILE_CONTENT
2021

21-
.PHONY: help init update logs
22+
.PHONY: help init update logs delete
2223

2324
help:
2425
@echo "This is a production only tool. Please use bun directly in development."
2526
@echo ""
2627
@echo "Run 'sudo make init' once, and then every time you want to update the website, run 'sudo make update'."
2728
@echo ""
2829
@echo "Rules:"
29-
@echo " - init: creates the service"
30+
@echo " - init: creates the service"
3031
@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"
32+
@echo " - update: updates and restarts"
33+
@echo " - logs: opens the logs"
34+
@echo " - delete: undoes init"
35+
@echo " - help: displays this message"
3436

3537
init:
36-
echo "$$SERVICE_FILE" | sudo tee /etc/systemd/system/$(SERVICE_NAME).service
38+
echo "$$SERVICE_FILE_CONTENT" | sudo tee $(SERVICE_FILE_PATH)
3739
sudo systemctl daemon-reload
3840
sudo systemctl enable $(SERVICE_NAME)
3941

@@ -48,6 +50,11 @@ update:
4850

4951
restart:
5052
sudo systemctl restart $(SERVICE_NAME)
53+
54+
delete:
55+
sudo systemctl stop $(SERVICE_NAME)
56+
sudo rm -f $(SERVICE_FILE_PATH)
57+
sudo systemctl daemon-reload
5158

5259
logs:
5360
sudo journalctl -xeu $(SERVICE_NAME)

0 commit comments

Comments
 (0)