FreemapSlovakia / freemap-mapnik

Outdoor map mainly for https://www.freemap.sk/
https://www.freemap.sk/?layers=X
Apache License 2.0
22 stars 9 forks source link

systemd freemap-mapnik.service is failing to start #309

Closed necarnot closed 6 months ago

necarnot commented 6 months ago

After having copied ./etc/systemd/freemap-mapnik.service into /etc/systemd/system/ folder and adapted it (username, password, database, working dir), trying to start it is leading to the following error :

déc. 27 22:58:53 freemap node[36059]: node:internal/modules/cjs/loader:1042
déc. 27 22:58:53 freemap node[36059]:   throw err;
déc. 27 22:58:53 freemap node[36059]:   ^
déc. 27 22:58:53 freemap node[36059]: Error: Cannot find module '/data/freemap-mapnik/index.js'
déc. 27 22:58:53 freemap node[36059]:     at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
déc. 27 22:58:53 freemap node[36059]:     at Module._load (node:internal/modules/cjs/loader:885:27)
déc. 27 22:58:53 freemap node[36059]:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
déc. 27 22:58:53 freemap node[36059]:     at node:internal/main/run_main_module:23:47 {
déc. 27 22:58:53 freemap node[36059]:   code: 'MODULE_NOT_FOUND',
déc. 27 22:58:53 freemap node[36059]:   requireStack: []
déc. 27 22:58:53 freemap node[36059]: }
déc. 27 22:58:53 freemap node[36059]: Node.js v18.13.0
déc. 27 22:58:53 freemap systemd[1]: freemap-mapnik.service: Main process exited, code=exited, status=1/FAILURE

The content of the file is partialy this :

[...]
WorkingDirectory=/data/freemap-mapnik/
Environment=NODE_ENV=prerender
Environment=GDAL_CACHEMAX=256
Environment=UV_THREADPOOL_SIZE=16
Environment=FM_CUSTOM_SQL="set_backend_priority(pg_backend_pid(), 10),"
ExecStart=/usr/bin/node --max-old-space-size=4096 --unhandled-rejections=strict index.js
[...]

and indeed :

root@freemap:/data/freemap-mapnik# LANG=C ls -la /data/freemap-mapnik/index.js
ls: cannot access '/data/freemap-mapnik/index.js': No such file or directory

This folder has just been git pulled tonight.

root@freemap:/data/freemap-mapnik# LANG=C git status 
On branch develop
Your branch is up to date with 'origin/develop'.

Trying to run it manually (from the correct folder/user and with the same options) are obviously failing the same way.

zdila commented 6 months ago

You must first build it with npm run build and then you will find index.js in dist directory. Feel free to send PR with updated documentation.

necarnot commented 6 months ago

I tried to change /etc/systemd/system/freemap-mapnik.service updating the line ExecStart this way :

ExecStart=/usr/bin/node --max-old-space-size=4096 --unhandled-rejections=strict dist/index.js

and when starting the service and looking at the journalctl logs, it seems to be running well.

But, is it the intended way to do, or do we have to move the dist files out of here somehow?