Centos – How to make a init script instead of a service file

centosinit-scriptsysvinit

I'm installing rocket.chat on CentOS6, following this tutorial. It gives the first half of the instructions in CentOS7 and 6, but then when it comes to making it run as a service, it omits 6's instructions.

For CentOS7, it suggests making making a service file but since 6 uses init scripts and I don't know how to write init scripts, I'm like a kid in a labratory.

The service file has the following in it:

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

I've made a file /etc/init.d/rocketchat and made it executable. I pasted the above in but it obviously isn't liking a lot of that syntax when I run it.

How would this init script be different to a service?

Best Answer

It's a systemd service file. Place to /lib/systemd/system/ Or if you have no systemd, then use the initscript from the previous version of Rocket.Chat.

Related Question