Skip to content

pastash service

Lorenzo Mangani edited this page Mar 24, 2020 · 18 revisions

Installation

NPM Install

sudo npm install -g @pastash/pastash

GIT Install (latest)

git clone https://github.com/sipcapture/pastash/
cd pastash
npm install

note: optional plugins might fail to install in npm without their requirements libraries (libzmq, etc)


Running as SystemD service

Install add-to-systemd utility with npm

npm install -g add-to-systemd

Add a pastash service to systemd (will start it on boot)

add-to-systemd my-pastash-service "$(which pastash) --config_file=/path/to/my-pastash.conf"

Use systemctl to manage the service

systemctl start my-pastash-service

Running as Node Service

PM2

Install PM2

npm install -g pm2

Create a custom yml file

apps:
  - script   : bin/pastash
    name: 'pastash-logs' 
    args: ['--config_file=/opt/pastash.conf']

Launch using PM2

pm2 start /path/to/pastash.yml

Save PM2 Process Config

pm2 save

Enable PM2 Startup Script for your OS (autodetect)

pm2 startup

FOREVER

Install forever:

sudo npm install -g forever

Start Service

forever start pastash --config_file=/path/to/pastash.conf

Forever restarts your app when it crashes or stops for some reason. To restrict restarts to 5 you could use:

forever -m5 pastash --config_file=/path/to/pastash.conf

Manage Services:

forever list

Note the integer in the brackets and use it as following to stop a process:

forever stop 0

Restarting a running process goes:

forever restart 0

UPSTART

This sample upstart script will handle respawning paStash in the event that it crashes. It will give up attempts to respawn your application if it crashes 3 or more times in less than 15 seconds.

/etc/init/pastash_daemon.conf
description "paSTash Daemon"
author      "QXIP"

stop on shutdown

respawn
respawn limit 3 15

script
  export APP_HOME="/usr/src/pastash"
  cd $APP_HOME
  exec sudo -u user /usr/bin/node /usr/local/bin/pastash --config_dir=/opt/pastash/configs
end script
Clone this wiki locally