Systemctl configuration on AWS EC2 + AWS Linux2
-
Hi All,
I am trying to automate nodebb bring-up. I am using Amazon's EC2 with linux2.
Per the manual, my systemctl is as follows:
[Unit]
Description=NodeBB Service
After=system.slice multi-user.target mongod.service
After=syslog.target[Service]
Type=simple
User=nodebbStandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodebbEnvironment=NODE_ENV=production
WorkingDirectory=/home/nodebb/www/nodebb
ExecStart=/usr/bin/env node loader.js --no-silent --no-daemon
Restart=always[Install]
WantedBy=multi-user.targetMy first issue was that node was not found (the recommended nodejs setup is per-user and not global). I solved that by adding a link (ln -s) from the www directory to the latest node version, replacing the ExecStart with:
ExecStart=/usr/bin/env /home/nodebb/www/node_link loader.js --no-silent --no-daemon
NodeBB does start, however, it looks like the WorkingDirectory is not respected, as I am getting spawn npm ENOENT when attempting to install a plugin.
Any idea how to fix this?
Thanks!
JJ. -
@jjsagan spawn npm enoent means that npm isn't in your path when your start the NodeBB process.
-
Thank you @PitaJ , the same issue I had with node.
The paths to npm and node are dynamic, as they depend on the last version installed. I rely on .bashrc to set the path properly.
Is there a way in systemctl to source the path from the .bashrc of a user ("nodebb" in my case), prior to execution?