Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Systemd docs is not working #73

Closed
jhagberg opened this issue Aug 19, 2016 · 12 comments
Closed

Systemd docs is not working #73

jhagberg opened this issue Aug 19, 2016 · 12 comments

Comments

@jhagberg
Copy link

In this page

https://github.com/RocketChat/Rocket.Chat.Docs/blob/master/3.%20Installation/4.%20Manual%20Installation/PM2%2C%20Systemd%2C%20Upstart.md

The systemd guide is no longer valid.

https://github.com/RocketChat/DockerFiles.git does no longer exists

What is the best way to use systemd ?

@ghost
Copy link

ghost commented Sep 13, 2016

Are you using docker or the manual install?

@jhagberg
Copy link
Author

Manual install

@ghost
Copy link

ghost commented Sep 13, 2016

Create the service file /etc/systemd/system/rocketchat.service details below

[Unit]
Description=RocketChat Server

[Service]
ExecStart=/usr/local/bin/node /var/www/rocketchat/main.js    # Specify the location of node and location of main.js
Restart=always
RestartSec=10                                                # Restart service after 10 seconds if node service crashes
StandardOutput=syslog                                        # Output to syslog
StandardError=syslog                                         # Output to syslog
SyslogIdentifier=nodejs-example
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=3000 ROOT_URL=https://rocketchat.domain.com MONGO_URL=mongodb://localhost:27017/rocketchat  MAIL_URL=smtp://email@domain.com:password@smtp.domain.com:587/

[Install]
WantedBy=multi-user.target
  1. Enable the service
    systemctl enable rocketchat.service
  2. Start the service
    systemctl start rocketchat.service
  3. Verify it is running
    systemctl status rocketchat.service

@geekgonecrazy
Copy link
Contributor

@jackd90 thanks for sharing that! I'll update the documentation to include this.

geekgonecrazy added a commit that referenced this issue Sep 14, 2016
@ghost
Copy link

ghost commented Sep 14, 2016

No problem. This is only for Rocket Chat, mongodb service obviously needs to be started for the service to run unless mongodb is on another server.

@geekgonecrazy
Copy link
Contributor

geekgonecrazy commented Sep 14, 2016

@jackd90 absolutely. Our recommended way would be to install from repo's. So this should be setup out of the box

@jhagberg
Copy link
Author

jhagberg commented Sep 14, 2016

Thanks I created a multi systemd service file so I can enable several services to run in HA

rocketchat@.service

[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.service mongodb.service

[Service]
User=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=https://rocketchat.domain.com PORT=%i
ExecStart=/usr/local/bin/node /var/lib/rocketchat/Rocket.Chat/main.js
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat-%i

[Install]
WantedBy=multi-user.target

Then just activate the ports you want to run via
systemctl enable rocketchat@3000.service
systemctl enable rocketchat@3001.service
and so on. Very nice and easy.

@geekgonecrazy
Copy link
Contributor

@jhagberg fantastic! You mind if we use that, could be very helpful info to have in our docs

@jhagberg
Copy link
Author

You are welcome to use that!
systemd is very easy if you want to stop you can use wildcard
systemctl stop rocketchat*.service
To stop or all services.

Maybe update https://github.com/RocketChat/Rocket.Chat.Docs/tree/master/3.%20Installation/4.%20Manual%20Installation/Multiple%20Instances%20to%20Improve%20Performance

The forever-service is not the recommended way to run nodejs any longer.

@geekgonecrazy
Copy link
Contributor

@jhagberg much appreciated. Opened #85 to do that 👍

@jemus42
Copy link
Contributor

jemus42 commented Mar 26, 2017

I would appreciate an update for the multi-instance systemd case for docker, as I'm currently running mongo and Rocket.Chat from docker containers in systemd as per the docs.

I can see how the service file posted by jhagberg works but I'm too unfamiliar with both docker and systemd files to mess with it myself.

@madawadeshan
Copy link

@ghost Wow Awesome!! Thank you very much it's work for me 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants