Jump to content
×

Sytemd service script (no warranty or support)


Michael

If you run a linux distro such as ubuntu/centos7/fedora/arch linux/etc, it is more than likely it will use systemd as the init system. if your server is running any type of panel, like cpanel or plesk, you might want to contact your host. as sometimes they have their own way of doing things. your host will be able to tell you if your server's OS uses systemd (and if they can't tell you what init system it uses, i would highly recommend it is time to find a new host :P ). 

This guide will assume you are familiar with linux command line, and the applications it uses. if you are not, do not proceed any further. you can cause serious harm to your server if you simply do not know what you are doing. I also do not provide any warranty with this guide and i do not offer any support on it. i would highly recommend contacting your host and/or hiring a system admin at this point to proceed any further. again, i can not be held responsible for any damage you may do to your server by following this guide. with that out of the way, we can now continue. 

Requirements:

  • an good understand of the linux command line
  • what init system your OS is running
  • super user privileges
  • ssh access (in windows this can be access via an app called putty which is a free download, in mac os x and linux, use your terminal emulator to connect via ssh).

if you don't understand one or any of the above mentioned things in requirements, turn back NOW!

  1. you will need super user privileges to proceed, if you are logged in as root, you can use the commands as is, if not, you will need to prefix them with sudo or su.
  2. we will need to create a service file:
     touch /etc/systemd/system/babble-startup.service
  3. once the file has been created, we will need to open it in a editor, i will use nano here as vi drives me insane. 
  4. nano /etc/systemd/system/babble-startup.service

    once it is open, copy the following content in and replace the red text with the right information:

    Quote

    [Unit]
    Description=babble.js startup script

    [Service]
    ExecStart=node /path/to/babblejs/babble.js
    Restart=always
    RestartSec=10
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=babblejs
    #User=<a system user>
    #Group=<the group the user is apart of>
    Environment=NODE_ENV=production PORT=3000

    [Install]
    WantedBy=multi-user.target

  5. ctrl+o will save it, ctrl+x will exit out of nano. NOTE: have the port match what is in the babble.js/ACP for port. 
  6. enable the service:
    systemctl enable babble-startup.service
  7. start the service:
  8. systemctl start babble-startup.service
  9. check the status:
  10. systemctl status babble-startup.service

the init script should now be running, and if babble.js crashes or the server is restarted, it should now start the babble.js on its own. again this guide is without warranty and support and use at your own risk.

Edited by Michael



User Feedback

Recommended Comments

There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×