&sect.2025-06-02

In my directory, this is how I started a server.js to monitor mongodb status:

lexlai@n2Bookworm:~/nodejs_project/syslog_ng_capped_collection/web_monitor$ pwd
/home/alexlai/nodejs_project/syslog_ng_capped_collection/web_monitor
alexlai@n2Bookworm:~/nodejs_project/syslog_ng_capped_collection/web_monitor$ ls
index.html  server.js

alexlai@n2Bookworm:~/nodejs_project/syslog_ng_capped_collection/web_monitor$ node server.js
(node:5329) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5329) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
Server is running on port 48597
Connected to the database!
Watching for insertions in the 'Odroid01Replication' collection...

My node is under /home/alexlai/.bashrc

...
# fnm
FNM_PATH="/home/alexlai/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
  export PATH="$FNM_PATH:$PATH"
  eval "`fnm env`"
fi

And node_modules are in

alexlai@n2Bookworm:~/nodejs_project/syslog_ng_capped_collection/web_monitor$ ls ..
bootstrapRowsColsCron.html  index_cron.js  indexCronNew.js  inLaneTicker-48449.service  mongoshrc-rs.status.js  node_modules  package-lock.json   simpleLog.justlog  watchInsert.js
bootstrapRowsCols.html      indexCron.js   index.js         mongoshrc.js                nginx.index.html        package.json  resetAtMidnight.js  temp.js            web_monitor

How to write a servicefile mongodbMonitor.service?