support redis:// URLs for Railway compatibility

This commit is contained in:
Arkadiy Kukarkin
2025-12-24 15:52:15 +01:00
parent 1c8ff78006
commit 72f90ccc99
2 changed files with 19 additions and 2 deletions

9
railway.toml Normal file
View File

@@ -0,0 +1,9 @@
[build]
builder = "dockerfile"
dockerfilePath = "Dockerfile"
[deploy]
healthcheckPath = "/dynamic.js.php"
healthcheckTimeout = 30
restartPolicyType = "on_failure"
restartPolicyMaxRetries = 3

View File

@@ -24,15 +24,23 @@ type Redis struct {
func NewRedis(addr, password, prefix string) (*Redis, error) { func NewRedis(addr, password, prefix string) (*Redis, error) {
var opts *redis.Options var opts *redis.Options
var err error
// unix socket detection // redis:// URL detection
if strings.HasPrefix(addr, "/") { 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{ opts = &redis.Options{
Network: "unix", Network: "unix",
Addr: addr, Addr: addr,
Password: password, Password: password,
} }
} else { } else {
// host:port
opts = &redis.Options{ opts = &redis.Options{
Addr: addr, Addr: addr,
Password: password, Password: password,