Flags for listen and metrics address; fix in newRedirectPasteSuccess.txt.tmpl
Fixes #9
This commit is contained in:
parent
e26e37c97d
commit
b738116f8a
@ -1,4 +1,4 @@
|
|||||||
{{- if .Request.PostForm.deleteToken -}}
|
{{if .Request.PostForm.deleteToken -}}
|
||||||
{{.Request.Host}}/{{.Paste.Key}}?deleteToken={{.Paste.DeleteToken | urlquery}}
|
{{.Request.Host}}/{{.Paste.Key}}?deleteToken={{.Paste.DeleteToken | urlquery}}
|
||||||
{{else -}}
|
{{else -}}
|
||||||
{{.Request.Host}}/{{.Paste.Key}}
|
{{.Request.Host}}/{{.Paste.Key}}
|
||||||
|
@ -7,17 +7,20 @@ import (
|
|||||||
"gitea.hashru.nl/dsprenkels/rushlink"
|
"gitea.hashru.nl/dsprenkels/rushlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
var (
|
||||||
var databasePath string
|
databasePath = flag.String("database", "", "location of the database file")
|
||||||
|
httpListen = flag.String("listen", "127.0.0.1:8000", "listen address (host:port)")
|
||||||
|
metricsListen = flag.String("metrics_listen", "127.0.0.1:58614", "listen address for metrics (host:port)")
|
||||||
|
)
|
||||||
|
|
||||||
flag.StringVar(&databasePath, "database", "", "Location of the database file")
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if err := rushlink.Open(databasePath); err != nil {
|
if err := rushlink.Open(*databasePath); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
defer rushlink.Close()
|
defer rushlink.Close()
|
||||||
|
|
||||||
go rushlink.StartMetricsServer()
|
go rushlink.StartMetricsServer(*metricsListen)
|
||||||
rushlink.StartMainServer()
|
rushlink.StartMainServer(*httpListen)
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,7 @@ import (
|
|||||||
bolt "go.etcd.io/bbolt"
|
bolt "go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
func StartMetricsServer(addr string) {
|
||||||
METRICS_ADDR = "127.0.0.1:58614"
|
|
||||||
)
|
|
||||||
|
|
||||||
func StartMetricsServer() {
|
|
||||||
var (
|
var (
|
||||||
_ = promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
_ = promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||||
Namespace: "rushlink",
|
Namespace: "rushlink",
|
||||||
@ -45,7 +41,7 @@ func StartMetricsServer() {
|
|||||||
router.Handle("/metrics", promhttp.Handler()).Methods("GET")
|
router.Handle("/metrics", promhttp.Handler()).Methods("GET")
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Handler: router,
|
Handler: router,
|
||||||
Addr: METRICS_ADDR,
|
Addr: addr,
|
||||||
WriteTimeout: 15 * time.Second,
|
WriteTimeout: 15 * time.Second,
|
||||||
ReadTimeout: 15 * time.Second,
|
ReadTimeout: 15 * time.Second,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func recoveryMiddleware(next http.Handler) http.Handler {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartMainServer() {
|
func StartMainServer(addr string) {
|
||||||
// Initialize Gorilla router
|
// Initialize Gorilla router
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.Use(recoveryMiddleware)
|
router.Use(recoveryMiddleware)
|
||||||
@ -42,7 +42,7 @@ func StartMainServer() {
|
|||||||
|
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Handler: router,
|
Handler: router,
|
||||||
Addr: "127.0.0.1:8000",
|
Addr: addr,
|
||||||
WriteTimeout: 15 * time.Second,
|
WriteTimeout: 15 * time.Second,
|
||||||
ReadTimeout: 15 * time.Second,
|
ReadTimeout: 15 * time.Second,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user