mirror of
https://github.com/parkan/go-hauk.git
synced 2026-05-08 08:47:44 +02:00
support redis:// URLs for Railway compatibility
This commit is contained in:
9
railway.toml
Normal file
9
railway.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[build]
|
||||
builder = "dockerfile"
|
||||
dockerfilePath = "Dockerfile"
|
||||
|
||||
[deploy]
|
||||
healthcheckPath = "/dynamic.js.php"
|
||||
healthcheckTimeout = 30
|
||||
restartPolicyType = "on_failure"
|
||||
restartPolicyMaxRetries = 3
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user