3 Commits

Author SHA1 Message Date
6be68d4dee ingress
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-14 15:18:07 +01:00
54eeb17e9b ingress
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-14 15:16:45 +01:00
4a56fea33b timestamp added
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-01-14 15:09:41 +01:00
3 changed files with 43 additions and 1 deletions

View File

@ -29,4 +29,43 @@ spec:
ports: ports:
- containerPort: 8080 - containerPort: 8080
protocol: TCP protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: locative
spec:
type: ClusterIP
selector:
app: locsrv
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: locative
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production-http
spec:
tls:
- hosts:
- locative.hottis.de
secretName: locative-cert
rules:
- host: locative.hottis.de
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: http
port:
number: 8080

View File

@ -2,6 +2,7 @@ package main
import ( import (
"log" "log"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
"encoding/json" "encoding/json"
@ -30,6 +31,7 @@ type locativeEvent struct {
Latitude string `json:"latitude"` Latitude string `json:"latitude"`
Longitude string `json:"longitude"` Longitude string `json:"longitude"`
Person string `json:"person"` Person string `json:"person"`
Timestamp string `json:"timestamp"`
} }
@ -46,6 +48,7 @@ func main() {
person, err := dbh.GetPersonById(event.Device) person, err := dbh.GetPersonById(event.Device)
event.Person = person event.Person = person
event.Location = event.Id event.Location = event.Id
event.Timestamp = time.Now().Format("2006-01-02 15:04:05 MST")
event.Id = "" event.Id = ""
if err != nil { if err != nil {
log.Printf("Person unknown: %v", err) log.Printf("Person unknown: %v", err)

View File

@ -45,7 +45,7 @@ func (self *MqttHandle) Publish(topicPost string, message string) error {
} }
topic := fmt.Sprintf("%s/%s", self.pubTopic, topicPost) topic := fmt.Sprintf("%s/%s", self.pubTopic, topicPost)
token := self.client.Publish(topic, 0, false, message) token := self.client.Publish(topic, 0, true, message)
token.Wait() token.Wait()
if token.Error() != nil { if token.Error() != nil {
return fmt.Errorf("MQTT publish failed: %v", token.Error()) return fmt.Errorf("MQTT publish failed: %v", token.Error())