I know this question has been asked a bajillion times, but I just can't figure this out. I've read every page I can on the topic but nothing I've tried works.
Basically, I have a script in /etc/init.d that works fine from the command line but not on startup. I don't know if it's not running at all or it gets some kind of error.
Robinson is a home-grown Sinatra application.
First, here's the script that's in init.d:
#!/bin/sh
### BEGIN INIT INFO
# Provides: robinson
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: robinson initscript
# Description: robinson
### END INIT INFO
# Do NOT "set -e"
DAEMON=/home/terry/projects/robinson/dev/trunk/installation/control.rb
SCRIPT_NAME=/etc/init.d/robinson
INSTALLATION_PATH="/home/terry/projects/robinson/dev/trunk/installation"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
case "$1" in
start)
$DAEMON $INSTALLATION_PATH start
;;
stop)
$DAEMON $INSTALLATION_PATH stop
;;
restart)
$DAEMON $INSTALLATION_PATH restart
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
exit 3
;;
esac
:
So that script's in /etc/init.d. Its permissions are set like this:
init.d # ls -lh robinson
-rwxr-xr-x 1 root root 839 Nov 2 03:45 robinson
I ran update-rc.d on the script. In fact, I even tried running it to remove the script, then add it again:
init.d # sudo update-rc.d robinson remove
init.d # sudo update-rc.d robinson defaults
If I start the service at the command line...
init.d # sudo service robinson start
... the service works just fine.
The Sinatra app is extremely simple. Right now I'm just trying to get Sinatra working. Here's the entirety of config.ru:
require "rubygems"
require "sinatra"
require "sinatra/base"
# Robinson
class Robinson < Sinatra::Base
get '/*' do
return 'hello world'
end
end
# run request routine
run Robinson
This is the nginx configuration file for Robinson
# unicorn socket
upstream robinson_unicorn_server {
server unix:/srv/terry/robinson/sockets/unicorn.sock
fail_timeout=0;
}
unicorn.rb looks like this:
# set path to app that will be used to configure unicorn
@dir = '/home/terry/projects/robinson/dev/trunk/installation/'
worker_processes 3
working_directory @dir
timeout 30
# configure for Robinson
robinson_data = '/srv/terry/robinson'
# Specify path to socket unicorn listens to,
# we will use this in our nginx.conf later
listen "#{robinson_data}/sockets/unicorn.sock", :backlog => 64
# Set process id path
pid "#{robinson_data}/pids/unicorn.pid"
# Set log file paths
stderr_path "#{robinson_data}/logs/unicorn.stderr.log"
stdout_path "#{robinson_data}/logs/unicorn.stdout.log"
It might be worth noting that when I restart the server, no entries are added to unicorn.stderr.log.
Here's some system info:
Operating system: Ubuntu Linux 16.04.1
Kernel and CPU: Linux 4.4.0-98-generic on x86_64
nginx version: nginx/1.10.3 (Ubuntu)
Not sure what other info to give. Let me know if there's anything I should add.
Any help is appreciated.