1. Rvm Bundler Rails 3.1 Thin Ubuntu

    Fichier /etc/init.d sous Ubuntu pour démarrer son app dans son environnement propre

      #! /bin/sh
      ### BEGIN INIT INFO
      # Provides:       <app_name>
      # Required-Start: $syslog
      # Required-Stop:  $syslog
      # Should-Start:       $local_fs
      # Should-Stop:        $local_fs
      # Default-Start:  2 3 4 5
      # Default-Stop:       0 1 6
      # Short-Description:  <app_name> - Site Web
      # Description:        <app_name> - Site Web
      ### END INIT INFO
    
    
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
      DAEMON=$HOME/.rvm/gems/ruby-1.9.2-p180@<app_name>/bin/thin
      DESC="<app_name>"
      NAME=<app_name>_env
      PROJECT_PATH=/var/www/$NAME # env
    
      check_thin() {
        for i in `ps aux|grep thin|grep '<app_name>.thin'|grep 'sock'|awk '{print $2}'`; 
        do 
            echo "Thin on $i"; 
            sleep 1; 
        done
      }
    
      test -x $DAEMON || exit 0
    
      set -e
    
      case "$1" in
        start)
            echo "Starting $DESC ..."
            rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.2-p180@<app_name>' -c \
            'cd /var/www/<app_name>_env/current/ && bundle exec thin -C \
            /etc/thin/<app_name>_env.yml start'
            echo "$DESC is started !"
        ;;
        stop)
            echo "Stopping $DESC ..."
            rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.2-p180@<app_name>' -c \
            'cd /var/www/<app_name>_env/current/ && bundle exec thin -C \
            /etc/thin/<app_name>_env.yml stop'
            echo "$DESC is stopped !"
        ;;
        restart|force-reload)
            echo "Restarting $DESC ..."
            rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.2-p180@<app_name>' -c \
            'cd /var/www/<app_name>_env/current/ && bundle exec thin -C \
            /etc/thin/<app_name>_env.yml restart'
            echo "$DESC is started !"
        ;;
        status)
            echo "Status"
            check_thin
        ;;
        *)
            N=/etc/init.d/<app_name>
            echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
            exit 1
        ;;
      esac
    
      exit 0
    
     
  1. josephhurtado aime ce billet
  2. jlstar a publié ce billet