From 306e1b431098a2f84f82a17f5c3dfa82974d4eb5 Mon Sep 17 00:00:00 2001 From: Levi Olson Date: Thu, 3 Jan 2019 13:20:28 -0600 Subject: [PATCH] Debugging --- README.md | 12 ++++++++++++ main.go | 1 + weather-api.service | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 902c5c9..e1e9e3e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ # Dark Sky API Interface A Golang Server that interfaces with the Dark Sky API so my Chrome Extension can get the weather. +## Systemd + sudo useradd weatherapi -s /sbin/nologin -M + sudo cp weather-api.service /lib/systemd/system/. + ls -al /lib/systemd/system + sudo chmod 755 /lib/systemd/system/weather-api.service + # add the DARK_SKY_API_KEY to the weather-api.service file + sudo systemctl enable weather-api.service + sudo systemctl start weather-api.service + sudo journalctl -f -u weather-api + # or + sudo systemctl status weather-api.service + ## Thanks Much of the source I obtained from [github.com/shawntoffel/darksky](https://github.com/shawntoffel/darksky). So thank you [shawntoffel](https://github.com/shawntoffel) and [contributors](https://github.com/shawntoffel/darksky/graphs/contributors) for that amazing codebase! diff --git a/main.go b/main.go index 5fda9c8..53b37e2 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,7 @@ func main() { response, err := currentWeather(lat, long, apikey) if err != nil { c.JSON(http.StatusExpectationFailed, gin.H{"error": err.Error()}) + log.Printf("Error: %s\n", err) return } c.Header("Access-Control-Allow-Origin", "*") diff --git a/weather-api.service b/weather-api.service index 7470888..c7c1858 100644 --- a/weather-api.service +++ b/weather-api.service @@ -5,16 +5,16 @@ After=network.target [Service] Type=simple -User=weatherapi -Group=weatherapi +User=root +Group=root LimitNOFILE=1024 +Environment="DARK_SKY_API_KEY=\"\"" Restart=on-failure RestartSec=10 -startLimitIntervalSec=60 WorkingDirectory=/root/go/src/weather-api -ExecStart=/root/go/src/weather-api/weather-api +ExecStart=/bin/bash -c "/root/go/src/weather-api/weather-api" # make sure log directory exists and owned by syslog PermissionsStartOnly=true