From 72f90ccc99a8d9cf23caa187a293008f71546d87 Mon Sep 17 00:00:00 2001 From: Arkadiy Kukarkin Date: Wed, 24 Dec 2025 15:52:15 +0100 Subject: [PATCH] support redis:// URLs for Railway compatibility --- railway.toml | 9 +++++++++ store/redis.go | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 railway.toml diff --git a/railway.toml b/railway.toml new file mode 100644 index 0000000..7a2f354 --- /dev/null +++ b/railway.toml @@ -0,0 +1,9 @@ +[build] +builder = "dockerfile" +dockerfilePath = "Dockerfile" + +[deploy] +healthcheckPath = "/dynamic.js.php" +healthcheckTimeout = 30 +restartPolicyType = "on_failure" +restartPolicyMaxRetries = 3 diff --git a/store/redis.go b/store/redis.go index 7bb47aa..9749d3e 100644 --- a/store/redis.go +++ b/store/redis.go @@ -24,15 +24,23 @@ type Redis struct { func NewRedis(addr, password, prefix string) (*Redis, error) { var opts *redis.Options + var err error - // unix socket detection - if strings.HasPrefix(addr, "/") { + // redis:// URL detection + if strings.HasPrefix(addr, "redis://") || strings.HasPrefix(addr, "rediss://") { + opts, err = redis.ParseURL(addr) + if err != nil { + return nil, err + } + } else if strings.HasPrefix(addr, "/") { + // unix socket opts = &redis.Options{ Network: "unix", Addr: addr, Password: password, } } else { + // host:port opts = &redis.Options{ Addr: addr, Password: password,