mirror of
https://github.com/parkan/go-hauk.git
synced 2026-05-08 16:47:46 +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) {
|
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user