From 8100893d2a9798771a4d0de64be8c9a3569a3207 Mon Sep 17 00:00:00 2001 From: seanwelch Date: Sun, 16 Jun 2024 14:51:55 +0100 Subject: [PATCH] changes --- .github/workflows/server.yaml | 1 + server/main.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/server.yaml b/.github/workflows/server.yaml index c7db3ac..644bc0a 100644 --- a/.github/workflows/server.yaml +++ b/.github/workflows/server.yaml @@ -79,5 +79,6 @@ jobs: echo ${{ secrets.SUDO_PASSWORD }} | sudo -S systemctl stop farmec.service sudo rm -f /home/seanwelch/server/bin/main sudo cp /home/seanwelch/bin/main /home/seanwelch/server/bin/main + sudo chmod +x /home/seanwelch/server/bin/main echo ${{ secrets.SUDO_PASSWORD }} | sudo -S systemctl start farmec.service echo ${{ secrets.SUDO_PASSWORD }} | sudo -S systemctl restart nginx diff --git a/server/main.go b/server/main.go index 15ea414..2804e9c 100644 --- a/server/main.go +++ b/server/main.go @@ -4,6 +4,7 @@ import ( "database/sql" "log" "os" + "path/filepath" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" @@ -24,7 +25,16 @@ func main() { log.Fatal("Error loading configuration: ", err) } - database, err := sql.Open("sqlite3", "./database/database.db") + cwd, err := os.Getwd() + if err != nil { + log.Fatal("Error getting current working directory: ", err) + } + log.Println("Current working directory:", cwd) + + databasePath := filepath.Join(cwd, "database/database.db") + log.Println("Database path:", databasePath) + + database, err := sql.Open("sqlite3", databasePath) if err != nil { log.Fatal(err) }