Skip to content

Commit d70de55

Browse files
authored
Merge pull request #2 from Codaea/fixed
Refactor: Load environment variables using Overload and add systemd s…
2 parents cb5dd0d + cd68c68 commit d70de55

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"image"
77
"image/color"
88
"image/png"
9-
"log"
109
"os"
1110
"strings"
1211

@@ -19,10 +18,7 @@ import (
1918

2019
func main() {
2120

22-
err := godotenv.Load(".env")
23-
if err != nil {
24-
log.Fatal("Error loading .env file")
25-
}
21+
_ = godotenv.Overload(".env")
2622

2723
// printer setup
2824
printerPath, found := os.LookupEnv("PRINTER_PATH")

sample.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Thermal Printer Server
3+
After=network.target
4+
StartLimitIntervalSec=0
5+
[Service]
6+
Type=simple
7+
Restart=always
8+
RestartSec=1
9+
User=coda
10+
ExecStart=/home/coda/simpleprint/simpleprint
11+
EnvironmentFile=/home/coda/simpleprint/.env
12+
13+
[Install]
14+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)