update
This commit is contained in:
@@ -35,7 +35,8 @@ COPY go.sum .
|
|||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY main.go .
|
COPY main.go .
|
||||||
COPY telldus ./telldus
|
COPY pkg ./pkg
|
||||||
|
|
||||||
|
|
||||||
# Build the Go application
|
# Build the Go application
|
||||||
RUN go build main.go
|
RUN go build main.go
|
||||||
|
|||||||
BIN
db/telldus.db
BIN
db/telldus.db
Binary file not shown.
16
main.go
16
main.go
@@ -1,11 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/datastore"
|
"app/pkg/datastore"
|
||||||
"app/devices"
|
"app/pkg/devices"
|
||||||
"app/mqtt"
|
"app/pkg/mqtt"
|
||||||
"app/telldus"
|
"app/pkg/telldus"
|
||||||
daemon "app/telldus-daemon"
|
daemon "app/pkg/telldus-daemon"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -25,8 +25,6 @@ var eventMgr *devices.EventManager
|
|||||||
|
|
||||||
const maxEvents = 1000
|
const maxEvents = 1000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Initialize daemon manager
|
// Initialize daemon manager
|
||||||
daemonMgr = daemon.New()
|
daemonMgr = daemon.New()
|
||||||
@@ -140,8 +138,6 @@ func main() {
|
|||||||
log.Fatal(http.ListenAndServe(httpPort, setupRoutes()))
|
log.Fatal(http.ListenAndServe(httpPort, setupRoutes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func getRawEvents(w http.ResponseWriter, r *http.Request) {
|
func getRawEvents(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(eventMgr.GetRawEvents())
|
json.NewEncoder(w).Encode(eventMgr.GetRawEvents())
|
||||||
@@ -355,5 +351,3 @@ func getSensor(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(sensor)
|
json.NewEncoder(w).Encode(sensor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package devices
|
package devices
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/datastore"
|
"app/pkg/datastore"
|
||||||
"app/mqtt"
|
"app/pkg/mqtt"
|
||||||
"app/telldus"
|
"app/pkg/telldus"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package devices
|
package devices
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/datastore"
|
"app/pkg/datastore"
|
||||||
"app/telldus"
|
"app/pkg/telldus"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package mqtt
|
package mqtt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/datastore"
|
"app/pkg/datastore"
|
||||||
"app/telldus"
|
"app/pkg/telldus"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package mqtt
|
package mqtt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/datastore"
|
"app/pkg/datastore"
|
||||||
"app/telldus"
|
"app/pkg/telldus"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"app/telldus"
|
"app/pkg/telldus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Manager handles the telldusd daemon lifecycle
|
// Manager handles the telldusd daemon lifecycle
|
||||||
Reference in New Issue
Block a user