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