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}}
|
||||
{{else -}}
|
||||
{{.Request.Host}}/{{.Paste.Key}}
|
||||
|
@ -7,17 +7,20 @@ import (
|
||||
"gitea.hashru.nl/dsprenkels/rushlink"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var databasePath string
|
||||
var (
|
||||
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()
|
||||
|
||||
if err := rushlink.Open(databasePath); err != nil {
|
||||
if err := rushlink.Open(*databasePath); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer rushlink.Close()
|
||||
|
||||
go rushlink.StartMetricsServer()
|
||||
rushlink.StartMainServer()
|
||||
go rushlink.StartMetricsServer(*metricsListen)
|
||||
rushlink.StartMainServer(*httpListen)
|
||||
}
|
||||
|
@ -13,11 +13,7 @@ import (
|
||||
bolt "go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
const (
|
||||
METRICS_ADDR = "127.0.0.1:58614"
|
||||
)
|
||||
|
||||
func StartMetricsServer() {
|
||||
func StartMetricsServer(addr string) {
|
||||
var (
|
||||
_ = promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Namespace: "rushlink",
|
||||
@ -45,7 +41,7 @@ func StartMetricsServer() {
|
||||
router.Handle("/metrics", promhttp.Handler()).Methods("GET")
|
||||
srv := &http.Server{
|
||||
Handler: router,
|
||||
Addr: METRICS_ADDR,
|
||||
Addr: addr,
|
||||
WriteTimeout: 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
|
||||
router := mux.NewRouter()
|
||||
router.Use(recoveryMiddleware)
|
||||
@ -42,7 +42,7 @@ func StartMainServer() {
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: router,
|
||||
Addr: "127.0.0.1:8000",
|
||||
Addr: addr,
|
||||
WriteTimeout: 15 * time.Second,
|
||||
ReadTimeout: 15 * time.Second,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user