aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/main.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-10-24 15:57:32 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-10-24 16:01:05 -0400
commit235b8f871fdfa35f9595268d194d28a3de655ec0 (patch)
tree46f562fddffd38ee10d5e3d858dd80c088879689 /cmd/server/main.go
parente0d4a3e50921dc07e23ef9aa107bdc78b3adf176 (diff)
downloadgo-website-235b8f871fdfa35f9595268d194d28a3de655ec0.tar.gz
go-website-235b8f871fdfa35f9595268d194d28a3de655ec0.tar.xz
Unix sockets for redis. Page use FS interface. Clear redis func.v0.0.16
Additionally, Funcs can be passed in.
Diffstat (limited to 'cmd/server/main.go')
-rw-r--r--cmd/server/main.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/server/main.go b/cmd/server/main.go
index 21f7031..912cba0 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -6,6 +6,8 @@ import (
"log"
"net/http"
"os"
+ "strings"
+ "text/template"
"time"
"github.com/gomodule/redigo/redis"
@@ -73,6 +75,11 @@ func main() { //nolint:funlen
MaxActive: 12000, //nolint:gomnd
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", *redisAddr)
+
+ if strings.HasPrefix(*redisAddr, "unix:") {
+ c, err = redis.Dial("unix", strings.TrimPrefix(*redisAddr, "unix:"))
+ }
+
if err != nil {
log.Println("Redis dial error: ", err)
}
@@ -87,6 +94,10 @@ func main() { //nolint:funlen
os.Stderr.Write(b)
}
+ page.Funcs = template.FuncMap{
+ "ClearRedis": app.ClearRedis,
+ }
+
srv := &http.Server{
Handler: app,
Addr: *listen,