Skip to content

Create Monkshu Service on Linux CentOS Ubuntu

TekMonks edited this page Feb 10, 2021 · 2 revisions
  1. If needed, permit node to bind to lower ports using this command - sudo setcap 'cap_net_bind_service=+ep' `which node` . Monkshu runs as a regular OS process, not a privileged process and never as root.

  2. Download crashguard using git clone https://github.com/TekMonksGitHub/crashguard.git

  3. Copy [monkshu_path]/crashguard.process.json to [crashguard_path]/conf/process.json. E.g. cp ~myapp/monkshu/crashguard.process.json ~myapp/crashguard/conf/process.json.

  4. Edit the file [crashguard_path]/conf/process.json and fix the paths inside the file to match your setup.

  5. Test the configuration works by running crashguard, e.g. - node ~/crashguard/crashguard.js. If this works both the backend and frontend servers should be started and the console will display the appropriate messages.

  6. If the test above works, kill crashguard using Ctrl+C or the kill command. We will now setup crashguard to start as a system service.

  7. Copy the file [monkshu_path]/monkshu.service to /usr/lib/systemd/system. E.g. cp ~myapp/monkshu/monkshu.service /usr/lib/systemd/system.

  8. Edit this file using this command vi /usr/lib/systemd/system/monkshu.service and fix these lines to match the Monkshu user and path on your system

User=monkshu
ExecStart=/usr/bin/env node /home/monkshu/crashguard/crashguard.js
  1. Enable the service using systemctl enable monkshu.

  2. Start the service using systemctl start monkshu.

  3. Run this command to ensure Monkshu is running cleanly - systemctl status monkshu. The output should show active (running) as below.

monkshu.service - Monkshu service
     Loaded: loaded (/lib/systemd/system/monkshu.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-02-10 05:04:19 UTC; 6s ago
   Main PID: 29309 (node)
      Tasks: 31 (limit: 1137)
     Memory: 26.9M
     CGroup: /system.slice/monkshu.service
             ├─29309 node /home/myapp/crashguard/crashguard.js
             ├─29326 /bin/bash /home/myapp/monkshu/frontend/server/server.sh
             ├─29327 /bin/bash /home/myapp/monkshu/backend/server/server.sh
             ├─29332 node /home/myapp/monkshu/frontend/server/server.js
             └─29333 node /home/myapp/monkshu/backend/server/server.js

Feb 10 05:04:19 myapp systemd[1]: Started Monkshu service.
Feb 10 05:04:19 myapp env[29309]: / /
Feb 10 05:04:19 myapp env[29309]: Starting...
Feb 10 05:04:19 myapp env[29309]: Initializing the logs.
Feb 10 05:04:19 myapp env[29309]: Starting...
Feb 10 05:04:19 myapp env[29309]: Initializing the logs.
Feb 10 05:04:19 myapp env[29309]: Server started on 0.0.0.0:443
Feb 10 05:04:19 myapp env[29309]: Server started on 0.0.0.0:9090
Clone this wiki locally