Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm not familiar with Ubuntu and some problem with server settings for my Rails app.

I've created deployer user in admin group (%admin ALL=(ALL) ALL). It was all ok, but when I'm trying to start Unicorn service, getting Permission denied message:

deployer@myvpsserver:~$ /etc/init.d/unicorn_myapp start
-bash: /etc/init.d/unicorn_myapp: Permission denied

Here is my /etc/init.d/unicorn_myapp:

!/bin/sh
### BEGIN INIT INFO
# Provides:          unicorn
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Manage unicorn server
# Description:       Start, stop, restart unicorn server for a specific application.
### END INIT INFO
set -e

# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/deployer/apps/myapp/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
AS_USER=deployer
set -u

OLD_PIN="$PID.oldbin"

sig () {
  test -s "$PID" && kill -$1 `cat $PID`
}

oldsig () {
  test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
}

run () {
  if [ "$(id -un)" = "$AS_USER" ]; then
    eval $1
  else
    su -c "$1" - $AS_USER
  fi
}

case "$1" in
start)
  sig 0 && echo >&2 "Already running" && exit 0
  run "$CMD"
  ;;
stop)
  sig QUIT && exit 0
  echo >&2 "Not running"
  ;;
force-stop)
  sig TERM && exit 0
  echo >&2 "Not running"
  ;;
restart|reload)
  sig HUP && echo reloaded OK && exit 0
  echo >&2 "Couldn't reload, starting '$CMD' instead"

Result of ls -l /etc/init.d/unicorn_myapp

lrwxrwxrwx 1 root root 63 Aug  8 23:13 /etc/init.d/unicorn_myapp ->      
/home/deployer/apps/myapp/current/config/unicorn_init.sh
share|improve this question
    
Can you post your /etc/init.d/unicorn_myapp script? Also, post the output from ls -l /etc/init.d/unicorn_myapp –  Chris McCauley Aug 9 '12 at 8:40
    
I've added unicorn_myapp :) –  ANATHEM Aug 9 '12 at 9:25

1 Answer 1

up vote 1 down vote accepted

You might need sudo /etc/init.d/unicorn_myapp start, or else set the executable bit on the init script with chmod a+x /etc/init.d/unicorn_myapp. None of this is Ubuntu-specific stuff, though.

share|improve this answer
    
Thanks! When I've tried sudo /etc/init.d/unicorn_myapp start [sudo] password for deployer: mypass sudo: /etc/init.d/unicorn_myapp: command not found I'll try to change mode in some minutes. –  ANATHEM Aug 9 '12 at 8:21
    
With chmod anyway -bash: /etc/init.d/unicorn_turbostartum: Permission denied :( –  ANATHEM Aug 9 '12 at 8:27
    
So chmod that, too. –  womble Aug 9 '12 at 8:29
    
Thanks to you and Chris McCauley! With chmod a+x /home/deployer/apps/myapp/current/config/unicorn_init.sh it works now :) –  ANATHEM Aug 9 '12 at 9:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.