0

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
2
  • Can you post your /etc/init.d/unicorn_myapp script? Also, post the output from ls -l /etc/init.d/unicorn_myapp Aug 9 '12 at 8:40
  • I've added unicorn_myapp :)
    – Oleg Pasko
    Aug 9 '12 at 9:25
2

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.

4
  • 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.
    – Oleg Pasko
    Aug 9 '12 at 8:21
  • With chmod anyway -bash: /etc/init.d/unicorn_turbostartum: Permission denied :(
    – Oleg Pasko
    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 :)
    – Oleg Pasko
    Aug 9 '12 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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