Skip to content

Commit 8ed4f76

Browse files
committed
Improve DB username and runtime module path handling.
1 parent fa3cfa5 commit 8ed4f76

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
1515
- Reduce the frequency of socket checks on known active connections.
1616
- Deleting a record from a leaderboard that does not exist now succeeds.
1717
- Notification listings now use more accurate time in cacheable cursors.
18+
- Use "root" as the default database user if not otherwise specified.
19+
20+
### Fixed
21+
- Runtime module loading now correctly handles paths on non-UNIX environments.
1822

1923
## [2.0.2] - 2018-07-09
2024
### Added

main.go

+3
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ func dbConnect(multiLogger *zap.Logger, config server.Config) (*sql.DB, string)
168168
parsedUrl.RawQuery = query.Encode()
169169
}
170170

171+
if len(parsedUrl.User.Username()) < 1 {
172+
parsedUrl.User = url.User("root")
173+
}
171174
if len(parsedUrl.Path) < 1 {
172175
parsedUrl.Path = "/nakama"
173176
}

migrate/migrate.go

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ func Parse(args []string, logger *zap.Logger) {
123123
parsedUrl.RawQuery = query.Encode()
124124
}
125125

126+
if len(parsedUrl.User.Username()) < 1 {
127+
parsedUrl.User = url.User("root")
128+
}
126129
dbname := "nakama"
127130
if len(parsedUrl.Path) > 1 {
128131
dbname = parsedUrl.Path[1:]

server/runtime_module_cache.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func LoadRuntimeModules(startupLogger *zap.Logger, config Config) (map[string]lu
6161

6262
// Override before Package library is invoked.
6363
lua.LuaLDir = runtimeConfig.Path
64-
lua.LuaPathDefault = lua.LuaLDir + "/?.lua;" + lua.LuaLDir + "/?/init.lua"
64+
lua.LuaPathDefault = lua.LuaLDir + string(os.PathSeparator) + "?.lua;" + lua.LuaLDir + string(os.PathSeparator) + "?" + string(os.PathSeparator) + "init.lua"
6565
os.Setenv(lua.LuaPath, lua.LuaPathDefault)
6666

6767
startupLogger.Info("Initialising runtime", zap.String("path", lua.LuaLDir))
@@ -80,7 +80,7 @@ func LoadRuntimeModules(startupLogger *zap.Logger, config Config) (map[string]lu
8080
relPath, _ := filepath.Rel(lua.LuaLDir, path)
8181
name := strings.TrimSuffix(relPath, filepath.Ext(relPath))
8282
// Make paths Lua friendly.
83-
name = strings.Replace(name, "/", ".", -1)
83+
name = strings.Replace(name, string(os.PathSeparator), ".", -1)
8484
moduleCache.Add(&RuntimeModule{
8585
Name: name,
8686
Path: path,

0 commit comments

Comments
 (0)