pm2/test/bash/startup.sh
Daniel Tschinder fb8fbe117a feat(startup): Allow custom service names for startup scripts
Especially when running mutliple instances of pm2 on one machine with
the same user this helps to create multiple startup scripts for each of
the instance.
2017-10-25 10:16:51 +02:00

30 lines
910 B
Bash

#!/usr/bin/env bash
if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit
fi
SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
cd $file_path
$pm2 startup upstart -u $USER --hp $HOME --service-name abcdef
spec "should startup command generation exited succesfully with custom service-name"
test -e /etc/init.d/abcdef
spec "should have generated upstart file with custom service-name"
$pm2 unstartup upstart --service-name abcdef
spec "should have disabled startup with custom service-name"
! test -e /etc/init.d/abcdef
spec "should have deleted upstart file with custom service-name"
$pm2 startup upstart -u $USER --hp $HOME
spec "should startup command generation exited succesfully"
test -e /etc/init.d/pm2-$USER
spec "should have generated upstart file"
$pm2 unstartup upstart
spec "should have disabled startup"
! test -e /etc/init.d/pm2-$USER
spec "should have deleted upstart file"