Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

Configuration Files via NPM 'config' package not detected when run as systemd service. (Ubuntu 22.04.1 LTS)

$
0
0

I have a simple web application using Node/Express on an Ubuntu (22.04.1 LTS) Virtual Machine. It uses the NPM package 'config' to fetch environment variables that hold connection parameters for a database. When launched from the project root folder via terminal, it runs without issues. It successfully connects to mysql, runs the stored procedure and displays the table on the browser.

The issue arises specifically when it is run as a systemd service. See configuration below:

[Unit]Description=Node WebserverWants=Network.targetAfter=syslog.target network-online.target[Service]Type=simpleWorkingDirectory=/home/my_profile/Documents/project_folderExecStart=/bin/bash ./startWebApp.shRestart=on-failureRestartSec=10KillMode=process[Install]WantedBy=multi-user.target

The service starts up fine, but gives the warning of:

WARNING: No configurations found in configuration folder /home/my_profile/Documents/project_folder/config

While the client receives the following when accessing (database.host is the env variable ref):

Error: Configuration property "database.host" is not defined    at Config.get (/home/my_profile/Documents/project_folder/node_modules/config/lib/config.js:179:11)    at /home/my_profile/Documents/project_folder/src/routes/index.js:9:22    at Layer.handle [as handle_request] (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/layer.js:95:5)    at next (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/route.js:144:13)    at Route.dispatch (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/route.js:114:3)    at Layer.handle [as handle_request] (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/layer.js:95:5)    at /home/my_profile/Documents/project_folder/node_modules/express/lib/router/index.js:284:15    at Function.process_params (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/index.js:346:12)    at next (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/index.js:280:10)    at Function.handle (/home/my_profile/Documents/project_folder/node_modules/express/lib/router/index.js:175:3)

To me this looks like a permissions or relative pathing issue, but I'm new to systemd. Any ideas?

I've confirmed the paths and swapped them between absolute and relative for the ExecStart property of the .service file.


Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>