[ome-users] Running Omero as service in Ubuntu
Roger Leigh
r.leigh at dundee.ac.uk
Tue Sep 4 10:37:57 BST 2012
On 03/09/2012 15:05, Mailly Philippe wrote:
> I'm trying to configure omero starting as service in ubuntu. I have put
> in /etc/init.d the corresponding files :
>
> /etc/init.d/omero
> #! /bin/sh
> ### BEGIN INIT INFO
> # Provides: omero admin
There probably should not be a space here.
> # Required-Start: $remote_fs $syslog
> # Required-Stop: $remote_fs $syslog
You also need $network and postgresql here, or else it will potentially
fail due to the lack of database or network connectivity when starting.
> # Default-Start: 2
> # Default-Stop: 0
> # echo 0 > /proc/sys/net/ipv4/tcp_window_scaling
This belongs in /etc/sysctl.conf if you want it enabled/disabled at startup.
> case "$1" in
> start)
> sudo -u mcib /opt/OMERO/OMERO.server/bin/omero admin start ;;
> stop)
> sudo -u mcib /opt/OMERO/OMERO.server/bin/omero admin stop ;;
You should never need to use sudo in an initscript.
> status)
> sudo -u mcib /opt/OMERO/OMERO.server/bin/omero admin
> diagnostics ;;
status is different from diagnostics. See "Status Codes" in
invoke-rc.d(8). Use "omero admin status" here.
> *)
> echo 'usage: /etc/init.d/omero start|stop|status' ;;
> esac
>
>
> and
>
> /etc/init.d/omeroweb
>
> #! /bin/sh
> ### BEGIN INIT INFO
> # Provides: omeroweb
> # Required-Start: $remote_fs $syslog
> # Required-Stop: $remote_fs $syslog
Don't you need a dependency on omero here?
> I get this error message :
>
> sudo update-rc.d omero defaults
> update-rc.d: warning: omero start runlevel arguments (2 3 4 5) do not
> match LSB Default-Start values (2)
> update-rc.d: warning: omero stop runlevel arguments (0 1 6) do not match
> LSB Default-Stop values (0)
> System start/stop links for /etc/init.d/omero already exist.
Your script should be using 2345 and 016 as the default start and stop
values. It should be stopped in runlevels 1 and 6 or else it won't be
stopped when switching to single user mode or rebooting, only when
halting. Likewise for runlevels 3, 4 and 5; you still want it to run in
these runlevels as well, typically.
I've attached the init scripts that we use for our virtual appliance,
which should be useful as a basis for your own. Note that these (along
with other scripts which might be useful), are available in the
openmicroscopy.git repository at
https://github.com/openmicroscopy/openmicroscopy/tree/develop/docs/install/VM
They could be further improved for better Ubuntu integration by adding
LSB logging functions, but this is purely cosmetic.
I hope this helps, please let me know if you need any further assistance.
Kind regards,
Roger
--
Dr Roger Leigh -- Open Microscopy Environment
Wellcome Trust Centre for Gene Regulation and Expression,
College of Life Sciences, University of Dundee, Dow Street,
Dundee DD1 5EH Scotland UK Tel: (01382) 386364
The University of Dundee is a registered Scottish Charity, No: SC015096
-------------- next part --------------
#!/bin/bash
#
# /etc/init.d/omero
# Subsystem file for "omero" server
#
### BEGIN INIT INFO
# Provides: omero
# Required-Start: $local_fs $remote_fs $network $time postgresql
# Required-Stop: $local_fs $remote_fs $network $time postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OMERO.server
### END INIT INFO
RETVAL=0
prog="omero"
# Read configuration variable file if it is present
[ -r /etc/default/$prog ] && . /etc/default/$prog
OMERO_HOME=${OMERO_HOME:-"/home/omero/OMERO.server"}
OMERO_USER=${OMERO_USER:-"omero"}
start() {
echo -n $"Starting $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero admin start &> /dev/null && echo -n ' OMERO.server'
RETVAL=$?
[ "$RETVAL" = 0 ]
echo
}
stop() {
echo -n $"Stopping $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero admin stop &> /dev/null && echo -n ' OMERO.server'
RETVAL=$?
[ "$RETVAL" = 0 ]
echo
}
status() {
echo -n $"Status $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero admin status && echo -n ' OMERO.server running'
RETVAL=$?
echo
}
diagnostics() {
echo -n $"Diagnostics $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero admin diagnostics
RETVAL=$?
echo
}
clearlogs() {
LOGDIR=${LOGDIR:-${OMERO_HOME}/var/log}
TARFILE=${TARFILE:-omero-logs-$(date '+%F').tar.bz2}
echo -n $"Clearing logs $prog:"
cd $LOGDIR && tar -caf $TARFILE *.{err,out,log} && \
(for x in ${LOGDIR}/*.{err,out,log}; do : > $x ;done) && \
chown $OMERO_USER ${LOGDIR}/${TARFILE} && \
echo -n $" saved to $LOGFILE/$TARFILE:"
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
RETVAL=$?
;;
diagnostics)
diagnostics
RETVAL=$?
;;
clearlogs)
clearlogs
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status|diagnostics|clearlogs}"
RETVAL=1
esac
exit $RETVAL
-------------- next part --------------
#!/bin/bash
#
# /etc/init.d/omero
# Subsystem file for "omero" server
#
### BEGIN INIT INFO
# Provides: omero-web
# Required-Start: $local_fs $remote_fs $network $time omero postgresql
# Required-Stop: $local_fs $remote_fs $network $time omero postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OMERO.web
### END INIT INFO
RETVAL=0
prog="omero-web"
# Read configuration variable file if it is present
[ -r /etc/default/$prog ] && . /etc/default/$prog
# also read the omero config
[ -r /etc/default/omero ] && . /etc/default/omero
OMERO_HOME=${OMERO_HOME:-"/home/omero/OMERO.server"}
OMERO_USER=${OMERO_USER:-"omero"}
start() {
echo -n $"Starting $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero web start &> /dev/null && echo -n ' OMERO.web'
sudo -iu ${OMERO_USER} bash ${OMERO_HOME%OMERO.server}/nginx-control.sh start
RETVAL=$?
[ "$RETVAL" = 0 ]
}
stop() {
echo -n $"Stopping $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero web stop &> /dev/null && echo -n ' OMERO.web'
sudo -iu ${OMERO_USER} bash ${OMERO_HOME%OMERO.server}/nginx-control.sh stop
RETVAL=$?
[ "$RETVAL" = 0 ]
}
status() {
echo -n $"Status $prog:"
sudo -iu ${OMERO_USER} ${OMERO_HOME}/bin/omero web status
sudo -iu ${OMERO_USER} bash ${OMERO_HOME%OMERO.server}/nginx-control.sh status
RETVAL=$?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
More information about the ome-users
mailing list