diff --git a/docs/contributing.md b/docs/contributing.md index d8729a33..34ac895d 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -72,6 +72,8 @@ The documentation uses the binaries provided by the packages, but for the develo npx clusteriohost -> node packages/host npx clusterioctl -> node packages/ctl +By default node does not enable source maps, to get stack traces pointing to the `.ts` files you will need to pass `--enable-source-maps` to `node` or set the environment variable `NODE_OPTIONS=--enable-source-maps`. + Note that to use `clusterioctl` you will have to create a control config first: node packages/controller bootstrap create-ctl-config [admin-user] diff --git a/packages/create/create.js b/packages/create/create.js index cacb19ef..4c252f93 100755 --- a/packages/create/create.js +++ b/packages/create/create.js @@ -375,17 +375,26 @@ async function writeScripts(mode) { if (process.platform === "win32") { await safeOutputFile( "run-controller.cmd", - "@echo off\n.\\node_modules\\.bin\\clusteriocontroller.cmd run\n" + `\ +@echo off. +set "NODE_OPTIONS=--enable-source-maps %NODE_OPTIONS%" +\\node_modules\\.bin\\clusteriocontroller.cmd run +` ); } else { await safeOutputFile( "run-controller.sh", - "#!/bin/sh\nexec ./node_modules/.bin/clusteriocontroller run\n", + `\ +#!/bin/sh +export "NODE_OPTIONS=--enable-source-maps $NODE_OPTIONS" +exec ./node_modules/.bin/clusteriocontroller run +`, { mode: 0o755 }, ); await safeOutputFile( "systemd/clusteriocontroller.service", - `[Unit] + `\ +[Unit] Description=Clusterio Controller [Service] @@ -394,6 +403,7 @@ Group=${await groupIdToName(os.userInfo().gid)} WorkingDirectory=${process.cwd()} KillMode=mixed KillSignal=SIGINT +Environment=NODE_OPTIONS=--enable-source-maps ExecStart=${process.cwd()}/node_modules/.bin/clusteriocontroller run --log-level=warn [Install]