Reputation: 23
I'm trying to configure the automatic launch of Redmine after rebooting Debian 7.9, however, I can not do it. Usually I start Redmine with two commands:
To automate the startup, I created the LSBInitScript (/etc/init.d/redmine). https://wiki.debian.org/LSBInitScripts
The full content of the script:
#!/bin/bash
### BEGIN INIT INFO
# Provides: redmine
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redmine webrick
# Description: redmine webrick server autostart-script
### END INIT INFO
. /lib/lsb/init-functions
# Modify it to your configuration
DIR=/opt/redmine/current
# Start Redmine in daemon mode.
start(){
log_daemon_msg "Starting Redmine WebRick"
cd $DIR
log_progress_msg
ruby script/rails server webrick -e production -d > redmine-start.log 2>&1
log_progress_msg
log_end_msg 0
}
# Stop Redmine daemon
stop(){
log_daemon_msg "Stopping Redmine WebRick"
RUBYPID=`ps aux | grep "ruby script/rails server webrick -e production -d" | grep -v grep | awk '{print $2}'`
log_progress_msg
if [ "x$RUBYPID" != "x" ]; then
kill -2 $RUBYPID
fi
log_end_msg 0
}
# Check if Redmine is running
status(){
RUBYPID=`ps aux | grep "ruby script/rails server webrick -e production -d" | grep -v grep | awk '{print $2}'`
if [ "x$RUBYPID" = "x" ]; then
echo "* Redmine is not running"
else
echo "* Redmine is running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|force-reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
esac
I made the file /etc/init.d/redmine executable, added it to boot sequence via
update-rc.d redmine defaults
After rebooting the operating system, the redmine script is executed, as indicated by the redmine-start.log file, however, this file reports errors.
The full output is shown below:
/var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in `block in materialize ': Could not find json-1.8.3 in any of the sources ( Bundler :: GemNotFound)
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `map! '
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `materialize '
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in `specs'
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in `specs_for '
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in `requested_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in `requested_specs'
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in `setup '
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler.rb:127:in `setup '
from /var/lib/gems/1.9.1/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in `<top (required)> '
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require '
As far as I can judge, this error says that the file json-1.8.3 can not be found and, it would seem, the problem is that something did not install. However, if I try to start the redmine manually, i.e.
/etc/init.d/redmine start
That start will happen without errors. The next natural assumption was that the error is in the order of starting scripts after the system is booted. But this assumption did not give anything, because this line should ensure the launch of Redmine as late as possible.
Required-Start: $all
I also manually tried to pick up some order of loading, but this did not work. I get a similar negative result, if instead of /etc/init.d I add a script to /etc/rc.local and if instead of update-rc.d I use insserv.
Guides, other people's scripts give the same error, the mention of which I could not find in Google in the context of this situation.
How can I fix this problem?
Upvotes: 1
Views: 653
Reputation: 2970
Manually running scripts in /etc/init.d
is not a good idea. The script will be run with the enviroment inherited from your shell. So it is very well possible that something in your enviroment makes it work.
To start a service using its /etc/init.d
script, use service
, so: service redmine start
. This would likely fail as well, if this is really an environment issue.
Upvotes: 1