Amazon Linux 2 LTS and systemd

Have successfully installed Rocket.Chat on an Amazon Linux 2 LTS instance, and can run the app directly via:
export PORT=3000
export ROOT_URL=http://my-public-ip:3000/
export MONGO_URL=mongodb://localhost:27017/rocketchat
node /opt/Rocket.Chat/main.js

However, getting Rocket.Chat to run via systemd is not working. My /lib/systemd/system/rocketchat.service file looks like:

[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.target mongod.target
[Service]
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=root
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat
Environment=ROOT_URL=http://my-public-ip:3000/
Environment=PORT=3000
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
[Install]
WantedBy=multi-user.target

What I get with systemctl start rocketchat.service:

[root@ip-172-30-4-231 system]# systemctl status rocketchat.service -l
● rocketchat.service - The Rocket.Chat server
Loaded: loaded (/usr/lib/systemd/system/rocketchat.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2018-03-17 01:07:09 UTC; 13min ago
Process: 4148 ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js (code=exited, status=8)
Main PID: 4148 (code=exited, status=8)

Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at Function.Module._load (module.js:312:12)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at Module.require (module.js:364:17)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at require (module.js:380:17)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at Object. (/opt/Rocket.Chat/main.js:4:1)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at Module._compile (module.js:456:26)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at Object.Module._extensions…js (module.js:474:10)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal rocketchat[4148]: at Module.load (module.js:356:32)
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal systemd[1]: rocketchat.service: main process exited, code=exited, status=8/n/a
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal systemd[1]: Unit rocketchat.service entered failed state.
Mar 17 01:07:09 ip-172-30-4-231.ec2.internal systemd[1]: rocketchat.service failed.

What am I missing?

What is Amazon Linux 2 LTS based on? This is a new one to me…

“Amazon Linux 2 is the next generation of Amazon Linux. It includes the latest LTS kernel (4.9) tuned for enhanced performance on Amazon EC2, systemd support, newer versions of glibc, gcc and binutils, and an additional set of core packages for performance and security improvements.”

It’s the systemd part and getting Rocket.Chat to start on system boot that kicking my butt. All else appears to work well.

Not really very telling of what linux distro they based on. But based on the error looks like node_module wasn’t found. Make sure npm install finishes without error.

Also make sure you are on Node.js 8.x

Its the world’s largest cloud. I’m sure you can find out particulars of the OS. Yes Node runs fine. Rocket.Chat works great. Only need to get it start on system boot.

Am I the only one out there running Rocket.Chat on Amazon???

On Amazon no of course not. On Amazon using Amazon Linux yes… First I’ve encountered. It’s definitely not one of our officially supported distros. Ubuntu 16.04 on Amazon is and should work fine.

Try looking at: journalctl -u rocketchat and see what you see. Makes no sense why it would run different…

Only difference is maybe do: sudo su before you run manually and see what happens. That should make the runs nearly identical. But the logs should tell us something