Be compatible with Upstart
From @HLFH on February 11, 2017 10:40
Hi,
With Upstart, you can use setuid and setgid.
So, please migrate from SysVinit + Forever to Upstart + Forever.
Here is an example:
#!upstart
description "Wekan Upstart Script"
start on startup
stop on shutdown
expect fork
env NAME="Wekan"
env NODE_PATH="/home/username/.nvm/v0.10.40/bin"
env APPLICATION_PATH="/home/username/wekan/bundle/main.js"
env PIDFILE=/var/run/wekan.pid
env LOGFILE=/var/log/wekan.log
env MONGO_URL="mongodb://127.0.0.1:27017/wekan"
env ROOT_URL="http://127.0.0.1"
env MAIL_URL='smtp://user:[email protected]:25/'
env PORT="8080"
script
PATH=$NODE_PATH:$PATH
exec forever \
--pidFile $PIDFILE \
-a \
-l $LOGFILE \
--minUptime 5000 \
--spinSleepTime 2000 \
start $APPLICATION_PATH
end script
pre-stop script
PATH=$NODE_PATH:$PATH
exec forever stop $APPLICATION_PATH
end script
Copied from original issue: anselal/wekan#20
@HLFH I haven't used upstart yet. I will take a look at it.
From @xet7 on February 13, 2017 7:37
@HLFH
I haven't used upstart, I currently only use systemd on Ubuntu 16.04 or Debian 8: https://github.com/wekan/wekan/wiki/Install-and-Update#optional-run-wekan-as-service
@HLFH I think I will stick to SysVinit for Ubuntu 14, and migrate to systemd for ubuntu 16 so there will be the support possible from us, for both versions. Thanx @xet7
From @HLFH on February 13, 2017 15:11
@anselal Ubuntu 14.04 supports UpStart. SysVinit is obsolete for Wekan use, even on Ubuntu 14.04. With Upstart, you have setuid and setgid features, so you can run Wekan as wekan user and not as root, which is quite better in terms of security, isnt' it?
#!upstart
description "Wekan Upstart Script"
start on startup
stop on shutdown
expect fork
setuid wekan
setgid wekan
env NAME="Wekan"
env NODE_PATH="/var/www/wekan/.nvm/v0.10.48/bin"
env APPLICATION_PATH="/var/www/wekan/main.js"
env PIDFILE=/var/run/wekan.pid
env LOGFILE=/var/log/wekan.log
env MONGO_URL="mongodb://127.0.0.1:27017/wekan"
env ROOT_URL="https://wekan.example.com"
env MAIL_URL="smtp://[email protected]:[email protected]:25/"
env MAIL_FROM="[email protected]"
env PORT="8080"
script
exec 2>>/dev/.initramfs/wekan.log
set -x
PATH=$NODE_PATH:$PATH
exec forever \
--pidFile $PIDFILE \
-a \
-l $LOGFILE \
--minUptime 5000 \
--spinSleepTime 2000 \
start $APPLICATION_PATH
end script
pre-stop script
PATH=$NODE_PATH:$PATH
exec forever stop $APPLICATION_PATH
end script
If you think that there is a problem running wekan as root you can always edit the script and change the user running it. I will give upstart and systemd a try in the next releases, but as long as there are no problems with sysvinit I will stick with my implementation