[TS] InitModule not executed with javascript module on Docker

After building TS files from this doc and starting the nakama docker : InitModule function seems to not be executed.

nakama logs :

docker-compose logs -f nakama                                                                                                                                                                                                   
devserver-nakama-1  | + /nakama/nakama migrate up --database.address root@cockroachdb:26257
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.456Z","caller":"migrate/migrate.go:155","msg":"Database connection","dsn":"postgres://root@cockroachdb:26257/nakama?sslmode=prefer"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.469Z","caller":"migrate/migrate.go:203","msg":"Database information","version":"CockroachDB CCL v20.2.19 (x86_64-unknown-linux-gnu, built 2022/02/09 18:48:48, go1.13.14)"}   
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.518Z","caller":"migrate/migrate.go:226","msg":"Successfully applied migration","count":0}
devserver-nakama-1  | + exec /nakama/nakama --config /nakama/data/my-config.yml --database.address root@cockroachdb:26257 --session.token_expiry_sec 7200 --metrics.prometheus_port 9100
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.531Z","caller":"server/config.go:89","msg":"Successfully loaded config file","path":"/nakama/data/my-config.yml"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.531Z","caller":"main.go:103","msg":"Nakama starting"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.531Z","caller":"main.go:104","msg":"Node","name":"nakama-node-1","version":"3.16.0+27ba93d3","runtime":"go1.20.3","cpu":16,"proc":16}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.531Z","caller":"main.go:105","msg":"Data directory","path":"./data/"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.531Z","caller":"main.go:124","msg":"Database connections","dsns":["root@cockroachdb:26257"]}
devserver-nakama-1  | {"level":"debug","ts":"2023-06-27T15:06:59.532Z","caller":"server/db.go:69","msg":"Complete database connection URL","raw_url":"postgres://root@cockroachdb:26257/nakama?sslmode=prefer"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.534Z","caller":"main.go:130","msg":"Database information","version":"CockroachDB CCL v20.2.19 (x86_64-unknown-linux-gnu, built 2022/02/09 18:48:48, go1.13.14)"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.536Z","caller":"server/metrics.go:176","msg":"Starting Prometheus server for metrics requests","port":9100}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.561Z","caller":"server/leaderboard_rank_cache.go:117","msg":"Initializing leaderboard rank cache"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.561Z","caller":"server/leaderboard_rank_cache.go:249","msg":"Leaderboard rank cache initialization completed successfully","cached":[],"skipped":[]}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime.go:621","msg":"Initialising runtime","path":"data/modules"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime.go:628","msg":"Initialising runtime event queue processor"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime.go:630","msg":"Runtime event queue processor started","size":65536,"workers":8}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_go.go:2643","msg":"Initialising Go runtime provider","path":"data/modules"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_go.go:2667","msg":"Go runtime modules loaded"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_lua.go:113","msg":"Initialising Lua runtime provider","path":"data/modules"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_lua.go:1200","msg":"Lua runtime modules loaded"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_lua.go:1203","msg":"Allocating minimum Lua runtime pool","count":16}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_lua.go:1211","msg":"Allocated minimum Lua runtime pool"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.562Z","caller":"server/runtime_javascript.go:612","msg":"Initialising JavaScript runtime provider","path":"data/modules","entrypoint":""}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.563Z","caller":"server/runtime_javascript.go:1688","msg":"JavaScript runtime modules loaded"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.563Z","caller":"server/runtime_javascript.go:1691","msg":"Allocating minimum JavaScript runtime pool","count":16}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.579Z","caller":"server/runtime_javascript.go:1699","msg":"Allocated minimum JavaScript runtime pool"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.579Z","caller":"server/runtime.go:663","msg":"Found runtime modules","count":1,"modules":["index.js"]}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.579Z","caller":"server/api.go:136","msg":"Starting API server for gRPC requests","port":7349}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.580Z","caller":"server/api.go:287","msg":"Starting API server gateway for HTTP requests","port":7350}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.582Z","caller":"server/console.go:218","msg":"Starting Console server for gRPC requests","port":7348}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.582Z","caller":"server/console.go:321","msg":"Starting Console server gateway for HTTP requests","port":7351}
devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.650Z","caller":"main.go:189","msg":"Startup done"}

docker-compose exec nakama cat /nakama/data/modules/index.js :

"use strict";
var InitModule = function (ctx, logger, nk, initializer) {
    logger.info("Hello World!");
};

What could prevent this ?

Find a solution : It was javascript runtime entry-point not set : --runtime.env “entrypoint=”

Thinked it was the silution but I still dont get “hello world” log :

devserver-nakama-1  | + /nakama/nakama migrate up --database.address root@cockroachdb:26257
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.464Z","caller":"migrate/migrate.go:155","msg":"Database connection","dsn":"postgres://root@cockroachdb:26257/nakama?sslmode=prefer"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.475Z","caller":"migrate/migrate.go:203","msg":"Database information","version":"CockroachDB CCL v20.2.19 (x86_64-unknown-linux-gnu, built 2022/02/09 18:48:48, go1.13.14)"}        
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.526Z","caller":"migrate/migrate.go:226","msg":"Successfully applied migration","count":0}
devserver-nakama-1  | + exec /nakama/nakama --config /nakama/data/my-config.yml --database.address root@cockroachdb:26257 --session.token_expiry_sec 7200 --metrics.prometheus_port 9100
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.537Z","caller":"server/config.go:89","msg":"Successfully loaded config file","path":"/nakama/data/my-config.yml"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.538Z","caller":"main.go:103","msg":"Nakama starting"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.538Z","caller":"main.go:104","msg":"Node","name":"nakama-node-1","version":"3.16.0+27ba93d3","runtime":"go1.20.3","cpu":16,"proc":16}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.538Z","caller":"main.go:105","msg":"Data directory","path":"./data/"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.538Z","caller":"main.go:124","msg":"Database connections","dsns":["root@cockroachdb:26257"]}
devserver-nakama-1  | {"level":"debug","ts":"2023-06-28T07:38:32.538Z","caller":"server/db.go:69","msg":"Complete database connection URL","raw_url":"postgres://root@cockroachdb:26257/nakama?sslmode=prefer"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.540Z","caller":"main.go:130","msg":"Database information","version":"CockroachDB CCL v20.2.19 (x86_64-unknown-linux-gnu, built 2022/02/09 18:48:48, go1.13.14)"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.543Z","caller":"server/metrics.go:176","msg":"Starting Prometheus server for metrics requests","port":9100}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.566Z","caller":"server/leaderboard_rank_cache.go:117","msg":"Initializing leaderboard rank cache"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.566Z","caller":"server/runtime.go:621","msg":"Initialising runtime","path":"data/modules"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime.go:628","msg":"Initialising runtime event queue processor"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.566Z","caller":"server/leaderboard_rank_cache.go:249","msg":"Leaderboard rank cache initialization completed successfully","cached":[],"skipped":[]}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime.go:630","msg":"Runtime event queue processor started","size":65536,"workers":8}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_go.go:2643","msg":"Initialising Go runtime provider","path":"data/modules"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_go.go:2667","msg":"Go runtime modules loaded"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_lua.go:113","msg":"Initialising Lua runtime provider","path":"data/modules"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_lua.go:1200","msg":"Lua runtime modules loaded"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_lua.go:1203","msg":"Allocating minimum Lua runtime pool","count":16}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_lua.go:1211","msg":"Allocated minimum Lua runtime pool"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.567Z","caller":"server/runtime_javascript.go:612","msg":"Initialising JavaScript runtime provider","path":"data/modules","entrypoint":"build/index.js"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.568Z","caller":"server/runtime_javascript.go:1688","msg":"JavaScript runtime modules loaded"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.568Z","caller":"server/runtime_javascript.go:1691","msg":"Allocating minimum JavaScript runtime pool","count":16}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.582Z","caller":"server/runtime_javascript.go:1699","msg":"Allocated minimum JavaScript runtime pool"}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.582Z","caller":"server/runtime.go:663","msg":"Found runtime modules","count":1,"modules":["index.js"]}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.582Z","caller":"server/api.go:136","msg":"Starting API server for gRPC requests","port":7349}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.582Z","caller":"server/api.go:287","msg":"Starting API server gateway for HTTP requests","port":7350}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.585Z","caller":"server/console.go:218","msg":"Starting Console server for gRPC requests","port":7348}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.585Z","caller":"server/console.go:321","msg":"Starting Console server gateway for HTTP requests","port":7351}
devserver-nakama-1  | {"level":"info","ts":"2023-06-28T07:38:32.692Z","caller":"main.go:189","msg":"Startup done"}

docker-compose exec nakama cat /nakama/data/modules/build/index.js :

"use strict";
var InitModule = function (ctx, logger, nk, initializer) {
    logger.info("Hello World!");
};

In fact logger.info and logger.debug doesn’t printing in the logs, I have no clue why… Tried to register rpc function in InitModule and all worked…

Hello @xenicle,

You can see in line:

devserver-nakama-1  | {"level":"info","ts":"2023-06-27T15:06:59.579Z","caller":"server/runtime.go:663","msg":"Found runtime modules","count":1,"modules":["index.js"]}

that the module is being loaded correctly, perhaps there’s something wrong with the configuration, is the logger level being set to debug?

You can check the currently configured values by accessing the Nakama Console

Hello @sesposito,

As you can see here :

logger level is set to debug.

also in the config yml there is :

logger:
    stdout: false
    level: "debug"
    file: "/nakama/data/logfile.log"

The stdout: false option will prevent the logger from writing to the terminal output, remove that line or set it to true and you’ll see the logs in the terminal.

As per the configuration, you’ll also find the logs in /nakama/data/logfile.log.

Best