refactor: remove main.go

Signed-off-by: martin <martin.labat92@gmail.com>
This commit is contained in:
martin 2023-02-17 20:20:36 +01:00
parent b5ced9df2c
commit abce8035f3
No known key found for this signature in database
GPG key ID: 4544CC55835A3B9E
3 changed files with 23 additions and 32 deletions

View file

@ -1,6 +1,6 @@
# 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">
<img src="img/immich.png" width=100> &nbsp; <img src="img/prometheus.png" width=100><img src="img/golang.png" width=100>

View file

@ -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

View file

@ -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)
}