Strider-CD / strider

Open Source Continuous Integration & Deployment Server
http://strider-cd.github.io/
4.59k stars 432 forks source link

How to run strider as a daemon service in EC2? #743

Open chenweiyj opened 9 years ago

chenweiyj commented 9 years ago

I find the document of strider shows we can run strider by typing strider in the terminal. However, it does not show how to run it as a daemon service. I write a service script to put it into /etc/init.d/. But the strider process is killed directly after started. I need some help. Thank you.

Here is my service script:

#!/bin/bash
#
# chkconfig: 35 90 12
# description: strider server
#
# Get function from functions library
. /etc/init.d/functions
# Start the service strider
start() {
        echo -n $"Starting strider CI server: "
        PORT=3888 SERVER_NAME="http://ec2-ip:3888" /home/ec2-user/.nvm/v0.10.36/bin/strider &
        ### Create the lock file ###
        touch /var/lock/subsys/strider
        success $"strider server startup"
        echo
}
# Restart the service strider
stop() {
        echo -n $"Stopping strider server: "
        killproc strider
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/strider
        echo
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status strider
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit 0
fernandoneto commented 9 years ago

instead put the script in /etc/init.d creat a script in /etc/init/ and use something like this

#!upstart
description "Strider upstart job"

start on (local-filesystems and net-device-up IFACE!=lo)
stop on shutdown

script
    export PORT=
    export DB_URI=""
    export SMTP_HOST=""
    export SMTP_PORT=""
    export SMTP_USER=""
    export SMTP_PASS=""
    export SERVER_NAME=""
    export STRIDER_CLONE_DEST=""
    export PLUGIN_GITHUB_APP_ID=""
    export PLUGIN_GITHUB_APP_SECRET=""
    echo $$ > /var/run/strider.pid
    exec  

/path/to/strider/bin/strider >> /var/log/strider.log 2>&1
end script

pre-start script
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/strider.log
end script

pre-stop script
    rm /var/run/strider.pid
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/strider.log
end script