domenkozar / almir

Bacula web administration written in Pyramid
Other
38 stars 13 forks source link

rc.d init script in FreeBSD 9.1 fails to autostart Almir #66

Closed igorfk closed 10 years ago

igorfk commented 10 years ago

Cannot start Almir via rc.d script in FreeBSD 9.1 with the following code: [/usr/local/etc/rc.d/almird]\=======================

#!/bin/sh
# PROVIDE: almird
# REQUIRE: DAEMON bacula_dir
. /etc/rc.subr
name="almird"
rcvar=almird_enable
start_cmd="${name}_start"
stop_cmd=":"
load_rc_config $name
almird_start()
{
PATH=/usr/local/www/almir/bin:/usr/local/bin:$PATH
/usr/local/bin/python2.7 -S /usr/local/www/almir/bin/pserve /usr/local/www/almir/production.ini --daemon --pid-file=/var/run/almird.pid --log-file=/usr/local/www/almir/var/log/almird.log
}
run_rc_command "$1"

\=====================================

The generated log (W.X.Y.Z is the local ip where Bacula, Apache and Almir are and some.domain.ex is the fqdn of the same machine): [/usr/local/www/almir/var/log/almird.log]\===========

Starting server in PID 742.
serving on http://W.X.Y.Z:2500
2014-07-17 21:02:02,340 ERROR [exc_logger][Dummy-1] http://some.domain.ex/
Traceback (most recent call last):
  File "/usr/local/www/almir/eggs/pyramid_exclog-0.5-py2.7.egg/pyramid_exclog/__init__.py", line 40, in exclog_tween
    return handler(request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/router.py", line 164, in handle_request
    response = view_callable(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 333, in rendered_view
    result = view(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 471, in _requestonly_view
    response = view(request)
  File "/usr/local/www/almir/almir/views.py", line 29, in dashboard
    upcoming_jobs = Job.get_upcoming()
  File "/usr/local/www/almir/almir/models.py", line 287, in get_upcoming
    return BConsole().get_upcoming_jobs()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 127, in get_upcoming_jobs
    p = self.start_process()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 69, in start_process
    return Popen(shlex.split(self.bconsole_command), stdout=PIPE, stdin=PIPE, stderr=PIPE)
  File "/usr/local/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
2014-07-17 21:02:02,388 ERROR [waitress][Dummy-1] Exception when serving /
Traceback (most recent call last):
  File "/usr/local/www/almir/eggs/waitress-0.8.1-py2.7.egg/waitress/channel.py", line 329, in service
    task.service()
  File "/usr/local/www/almir/eggs/waitress-0.8.1-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/usr/local/www/almir/eggs/waitress-0.8.1-py2.7.egg/waitress/task.py", line 380, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/router.py", line 187, in __call__
    response = self.handle_request(request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/tweens.py", line 20, in excview_tween
    response = handler(request)
  File "/usr/local/www/almir/eggs/pyramid_tm-0.3-py2.7.egg/pyramid_tm/__init__.py", line 61, in tm_tween
    response = handler(request)
  File "/usr/local/www/almir/eggs/pyramid_exclog-0.5-py2.7.egg/pyramid_exclog/__init__.py", line 40, in exclog_tween
    return handler(request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/router.py", line 164, in handle_request
    response = view_callable(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 333, in rendered_view
    result = view(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 471, in _requestonly_view
    response = view(request)
  File "/usr/local/www/almir/almir/views.py", line 29, in dashboard
    upcoming_jobs = Job.get_upcoming()
  File "/usr/local/www/almir/almir/models.py", line 287, in get_upcoming
    return BConsole().get_upcoming_jobs()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 127, in get_upcoming_jobs
    p = self.start_process()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 69, in start_process
    return Popen(shlex.split(self.bconsole_command), stdout=PIPE, stdin=PIPE, stderr=PIPE)
  File "/usr/local/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
2014-07-17 21:02:04,555 ERROR [exc_logger][Dummy-2] http://some.domain.ex/
Traceback (most recent call last):
  File "/usr/local/www/almir/eggs/pyramid_exclog-0.5-py2.7.egg/pyramid_exclog/__init__.py", line 40, in exclog_tween
    return handler(request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/router.py", line 164, in handle_request
    response = view_callable(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 333, in rendered_view
    result = view(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 471, in _requestonly_view
    response = view(request)
  File "/usr/local/www/almir/almir/views.py", line 29, in dashboard
    upcoming_jobs = Job.get_upcoming()
  File "/usr/local/www/almir/almir/models.py", line 287, in get_upcoming
    return BConsole().get_upcoming_jobs()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 127, in get_upcoming_jobs
    p = self.start_process()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 69, in start_process
    return Popen(shlex.split(self.bconsole_command), stdout=PIPE, stdin=PIPE, stderr=PIPE)
  File "/usr/local/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
2014-07-17 21:02:04,559 ERROR [waitress][Dummy-2] Exception when serving /
Traceback (most recent call last):
  File "/usr/local/www/almir/eggs/waitress-0.8.1-py2.7.egg/waitress/channel.py", line 329, in service
    task.service()
  File "/usr/local/www/almir/eggs/waitress-0.8.1-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/usr/local/www/almir/eggs/waitress-0.8.1-py2.7.egg/waitress/task.py", line 380, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/router.py", line 187, in __call__
    response = self.handle_request(request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/tweens.py", line 20, in excview_tween
    response = handler(request)
  File "/usr/local/www/almir/eggs/pyramid_tm-0.3-py2.7.egg/pyramid_tm/__init__.py", line 61, in tm_tween
    response = handler(request)
  File "/usr/local/www/almir/eggs/pyramid_exclog-0.5-py2.7.egg/pyramid_exclog/__init__.py", line 40, in exclog_tween
    return handler(request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/router.py", line 164, in handle_request
    response = view_callable(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 333, in rendered_view
    result = view(context, request)
  File "/usr/local/www/almir/eggs/pyramid-1.3-py2.7.egg/pyramid/config/views.py", line 471, in _requestonly_view
    response = view(request)
  File "/usr/local/www/almir/almir/views.py", line 29, in dashboard
    upcoming_jobs = Job.get_upcoming()
  File "/usr/local/www/almir/almir/models.py", line 287, in get_upcoming
    return BConsole().get_upcoming_jobs()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 127, in get_upcoming_jobs
    p = self.start_process()
  File "/usr/local/www/almir/almir/lib/bconsole.py", line 69, in start_process
    return Popen(shlex.split(self.bconsole_command), stdout=PIPE, stdin=PIPE, stderr=PIPE)
  File "/usr/local/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

\=====================================

But running after log in server, manually, as root, with the command: /usr/local/etc/rc.d/almird onestart Starts Almir without problem

domenkozar commented 10 years ago

Seems like "bconsole" command is missing, you need that installed (no idea what package is that for FreeBSD)

igorfk commented 10 years ago

You're right iEletric, the bconsole command, which comes with bacula in FreeBSD, cannot be found by the script. I had to add the path to that binary, and for some others too. The final script, more suitable for a FreeBSD environment, is this:

#!/bin/sh
# PROVIDE: almird
# REQUIRE: bacula_dir

. /etc/rc.subr

name="almird"
rcvar=${name}_enable
command="/usr/local/www/almir/bin/supervisord"
load_rc_config $name

: ${almird_enable="NO"}
: ${almird_flags=" --pidfile=/var/run/almird.pid --logfile=/usr/local/www/almir/var/log/almird.log --logfile_maxbytes 500000 --logfile_backups 5"}
: ${almird_pidfile="/var/run/almird.pid"}
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
pidfile="${almird_pidfile}"

run_rc_command "$1"
domenkozar commented 10 years ago

I'm glad it works, thanks for example file! :)