anchor.diff:  # description: Start-up file for Nagira monitoring component, Nagios RESTful API. See also: http://dmytro.github.com/nagira
   # processname: ruby ./nagira.rb
   # config: TBD
  -
  -init_rvm () {
  -    source /usr/local/rvm/scripts/rvm > /dev/null 2>&1 
  -    rvm use <%= APP[:rvm] %> --default > /dev/null 2>&1 
  -}
   
   process_name="Sinatra Nagira services"
   
  
positive.code:     # TODO: need testing
      local process=$(get_pid)
      kill $process
      RETVAL=$?
      sleep 2
      [ -z "$(get_pid)" ] && { echo OK; return $RETVAL; }
  
negative.code: 
  start() {
      [ ! -z "$(get_pid)" ] && { status; return 1; }
      echo -n $"Starting ${process_name}:    "
      su - <%=  APP[:run_as] %> -s /bin/bash -c "rvm use <%= APP[:rvm] %> && cd <%= $nagira_root %> && RACK_ENV=production bundle exec ./nagira.rb" > <%= APP[:log] %> 2>&1 &
      sleep 5
      process=$(get_pid)
      echo $process > $pid_file
      if [ -z "$process" ]; then
          echo "[FAIL]"
      else
          echo "[OK]"
      fi
  }
  
  