refactor: remove main.go
Signed-off-by: martin <martin.labat92@gmail.com>
This commit is contained in:
parent
b5ced9df2c
commit
abce8035f3
3 changed files with 23 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
||||||
# immich-exporter
|
# immich-exporter
|
||||||
|
|
||||||
[![manual push](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml/badge.svg)](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml)
|
[![Publish Release](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml/badge.svg)](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml)
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="img/immich.png" width=100> <img src="img/prometheus.png" width=100><img src="img/golang.png" width=100>
|
<img src="img/immich.png" width=100> <img src="img/prometheus.png" width=100><img src="img/golang.png" width=100>
|
||||||
|
|
22
src/init.go
22
src/init.go
|
@ -6,13 +6,35 @@ import (
|
||||||
"immich-exporter/src/immich"
|
"immich-exporter/src/immich"
|
||||||
"immich-exporter/src/models"
|
"immich-exporter/src/models"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"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() {
|
func startup() {
|
||||||
projectinfo()
|
projectinfo()
|
||||||
var envfile bool
|
var envfile bool
|
||||||
|
|
31
src/main.go
31
src/main.go
|
@ -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)
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue