diff --git a/README.md b/README.md index e1d958f..9eea173 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # immich-exporter -[](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml) +[](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml)
diff --git a/src/init.go b/src/init.go
index 876f682..c8a4e72 100644
--- a/src/init.go
+++ b/src/init.go
@@ -6,13 +6,35 @@ import (
"immich-exporter/src/immich"
"immich-exporter/src/models"
"io/ioutil"
+ "net/http"
"log"
"os"
"github.com/joho/godotenv"
+ "github.com/prometheus/client_golang/prometheus"
+ "github.com/prometheus/client_golang/prometheus/promhttp"
)
+func main() {
+ startup()
+ log.Println("Immich URL :", models.GetURL())
+ log.Println("username :", models.GetUsername())
+ log.Println("password :", models.Getpasswordmasked())
+ log.Println("Started")
+
+ http.HandleFunc("/metrics", metrics)
+ http.ListenAndServe(":8090", nil)
+}
+
+func metrics(w http.ResponseWriter, r *http.Request) {
+ registry := prometheus.NewRegistry()
+ immich.Allrequests(registry)
+ h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
+ h.ServeHTTP(w, r)
+
+}
+
func startup() {
projectinfo()
var envfile bool
diff --git a/src/main.go b/src/main.go
deleted file mode 100644
index c4b1e94..0000000
--- a/src/main.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package main
-
-import (
- "immich-exporter/src/immich"
- "immich-exporter/src/models"
-
- "log"
- "net/http"
-
- "github.com/prometheus/client_golang/prometheus"
- "github.com/prometheus/client_golang/prometheus/promhttp"
-)
-
-func main() {
- startup()
- log.Println("Immich URL :", models.GetURL())
- log.Println("username :", models.GetUsername())
- log.Println("password :", models.Getpasswordmasked())
- log.Println("Started")
-
- http.HandleFunc("/metrics", metrics)
- http.ListenAndServe(":8090", nil)
-}
-
-func metrics(w http.ResponseWriter, r *http.Request) {
- registry := prometheus.NewRegistry()
- immich.Allrequests(registry)
- h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
- h.ServeHTTP(w, r)
-
-}