/etc/init.d/openerp-server6
start|stop|restart|status, on:
[nom_instancia_oerp [-u nom_modul [-d nom_basedades […]]]]
$ sudo /etc/init.d/openerp-server6 start oerp6 -u training_dining_hall -d dining_hall
Aquesta comanda engegaria la instància oerp6 actualitzant el mòdul training_dining_hall de la base de dades dining_hall.
$ sudo /etc/init.d/openerp-server6 restart oerp6 -u training_dining_hall &
Aquesta comanda aturaria i engegaria la instància oerp6 actualitzant el mòdul training_dining_hall. Si s'utilitza per debugar codi de mòduls en desenvolupament, permet continuar treballant a la consola sense aturar el servidor i sense deixar de veure els logs. Per tornar a reengegar el servidor, no caldria aturar-lo amb Ctrl-C, només seria necessari tornar a executar aquesta comanda.
Permet la seva configuració per poder adaptar-lo a les necessitats de cada moment.
Si estem desenvolupant mòduls per a OpenERP, podem necessitar veure els logs del que està passant a la mateixa consola on engeguem el servidor. Per fer-ho, s'ha de posar la variable LOG a TRUE, en cas contrari, es posa a FALSE. En un servidor de producció s'ha de posar a FALSE pel seu correcte funcionament.
Exemple:
# Module's Development # FALSE or TRUE LOG=TRUE
Quan instal·lem un nou servidor, pot ser útil saber què està passant quan intentem engegar el servidor per saber què està fallant. Llavors s'ha de descomentar el set -x i comentar el set -e. Un cop la instal·lacio ja funciona correctament, s'ha de tornar a posar com estava.
Exemple:
# Installation debuger enabled #set -x # Installation debuger disabled set -e
Només s'utilitza per servidors saas, si no és el cas, s'han de comentar les dues línies de lectura del fitxer.
Exemple:
# If config file not exists, exit with error code 1 #[ ! -x /etc/openerp.conf ] && exit 1 # Load config file parameters #. /etc/openerp.conf
Aquests paràmetres són diferents de cada instal·lació, i per tant, s'ha de posar una especial atenció en el moment de posar els seus valors. Si la configuració es fa mitjançant el fitxer mencionat a l'apartat anterior, s'han de comentar tots. Són els següents:
Exemple:
# If not exist the config file changes its parameters by:
NAME="openerp-6"
SERVER="server"
CONFIGDIR="/etc/${NAME}"
INITDIR="/etc/init.d"
DAEMONDIR="/usr/bin"
SYSTEM_USER=openerp
#!/bin/sh
### BEGIN INIT INFO
# Provides: openerp-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enterprise Resource Management software
# Description: Open ERP is a complete ERP and CRM software.
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# If config file not exists, exit with error code 1
#[ ! -x /etc/openerp.conf ] && exit 1
# Load config file parameters
#. /etc/openerp.conf
# If not exist the config file changes its parameters by:
NAME="openerp-6"
SERVER="server"
CONFIGDIR="/etc/${NAME}"
INITDIR="/etc/init.d"
DAEMONDIR="/usr/bin"
SYSTEM_USER=openerp
# Module's Development
# FALSE or TRUE
LOG=TRUE
# Installation debuger enabled
#set -x
# Installation debuger disabled
set -e
# Assign order (start, stop, restart|force-reload, status)to $ORDER
if [ -z $1 ]; then
echo "Usage: ${NAME}-${SERVER} {start|stop|restart|force-reload|status} [server-name [openerp-options ]]" >&2
exit 1
fi
ORDER="${1}"
shift
# If a server parameter is given, sets the DB_USER variable with this parameter
if [ ! -z $1 ]; then
DB_USER="$1"
shift
fi
# Additional options that are passed to the Daemon.
PARAM=""
if [ $# -ge 1 ]; then
while [ ! -z "${1}" ]; do
PARAM="${PARAM} ${1}"
shift
done
fi
start_daemon () {
echo "Starting ${NAME}-${SERVER} ${DB_USER}: "
test -x ${DAEMONDIR}/${NAME}-${SERVER}_${DB_USER} || exit 0
if [ -f ${PIDFILE} ]; then
echo "${NAME}-${SERVER} ${DB_USER} already running: `cat ${PIDFILE}`"
return
fi
if [ $LOG = "TRUE" ] ; then
echo "\nstart-stop-daemon --start --pidfile ${PIDFILE} --chuid ${SYSTEM_USER} --make-pidfile --exec ${DAEMONDIR}/${NAME}-${SERVER}_${DB_USER} -- ${DAEMON_OPTS}"
start-stop-daemon --start --pidfile ${PIDFILE} --chuid ${SYSTEM_USER} --make-pidfile --exec ${DAEMONDIR}/${NAME}-${SERVER}_${DB_USER} -- ${DAEMON_OPTS}
else
start-stop-daemon --start --quiet --pidfile ${PIDFILE} --chuid ${SYSTEM_USER} --background --make-pidfile --exec ${DAEMONDIR}/${NAME}-${SERVER}_${DB_USER} -- ${DAEMON_OPTS}
fi
sleep 0.5
echo "${NAME}-${SERVER} ${DB_USER}: `cat ${PIDFILE}`: running."
}
stop_daemon () {
echo "Stopping ${NAME}-${SERVER} ${DB_USER}: "
while [ `ps -ef | grep python | grep openerp | grep server | grep ${DB_USER} | awk ' { print $2 } '` ] ; do
if [ -f ${PIDFILE} ]; then
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} #--oknodo
sleep 0.5
else
PID=`ps -ef | grep python | grep openerp | grep server | grep ${DB_USER} | awk ' { print $2 } '`
sudo kill -9 $PID
sleep 0.5
echo "pid $PID stopped."
fi
done
if [ -f ${PIDFILE} ]; then
echo "pid `cat ${PIDFILE}` stopped."
rm -f ${PIDFILE} # remove pidfile
else
echo "${NAME}-${SERVER} ${DB_USER}: not running"
fi
return
}
status_daemon(){
echo -n "Checking ${NAME}-${SERVER} ${DB_USER}: "
if [ -f ${PIDFILE} ]; then
echo "`cat ${PIDFILE}` running."
else
echo "stopped."
fi
}
case "${ORDER}" in
start)
if [ ${DB_USER} ] ; then
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
DAEMON_OPTS="--config=${CONFIGDIR}/.${NAME}_${SERVER}rc_${DB_USER} ${PARAM}"
start_daemon
else
for DB_USER in `ls -a ${CONFIGDIR}/.${NAME}_${SERVER}rc* | awk -v FS="_" '{print $3}'` ; do
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
DAEMON_OPTS="--config=${CONFIGDIR}/.${NAME}_${SERVER}rc_${DB_USER} ${PARAM}"
start_daemon
done
fi
;;
stop)
if [ ${DB_USER} ] ; then
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
stop_daemon
else
for DB_USER in `ls -a ${CONFIGDIR}/.${NAME}_${SERVER}rc* | awk -v FS="_" '{print $3}'` ; do
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
stop_daemon
done
fi
;;
restart)
if [ ${DB_USER} ] ; then
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
DAEMON_OPTS="--config=${CONFIGDIR}/.${NAME}_${SERVER}rc_${DB_USER} ${PARAM}"
stop_daemon
start_daemon
else
for DB_USER in `ls -a ${CONFIGDIR}/.${NAME}_${SERVER}rc* | awk -v FS="_" '{print $3}'` ; do
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
DAEMON_OPTS="--config=${CONFIGDIR}/.${NAME}_${SERVER}rc_${DB_USER} ${PARAM}"
stop_daemon
start_daemon
done
fi
;;
status)
if [ ${DB_USER} ] ; then
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
status_daemon
else
for DB_USER in `ls -a ${CONFIGDIR}/.${NAME}_${SERVER}rc* | awk -v FS="_" '{print $3}'` ; do
PIDFILE="/var/run/${NAME}-${SERVER}_${DB_USER}.pid"
status_daemon
done
fi
;;
*)
N=/etc/init.d/${NAME}-${SERVER}
echo "Usage: ${NAME}-${SERVER} {start|stop|restart|force-reload|status} [server-name [openerp-options ]]" >&2
exit 1
;;
esac
exit 0