DomotiGaServer-Upstart

Introduction

In the DomotiGaServer section of the wiki there's a System V script for stopping and starting the DomotiGaServer. Distributions however are moving towards the Ubuntu Upstart mechanism as it's a fastly improved way of stopping and starting services in newer releases of their distribution. For this reason a Upstart script for DomotiGaServer was created. This isn't part of the DomotiGa svn tree yet, so this needs to be copy/pasted from the webpage into a new file.

Location and permissions

RDNZL advises you to run domotiga under your username and place domotiga in your homedirectory.
Some people however tend to feel more comfortable deviating from that advise and run domotiga from /opt. In most cases people run DomotiGaServer under their own username, some however create a separate user for the DomotiGaServer service.

Assumptions

script name: domotiga.conf
script location: /etc/init
Gambas: compiled from svn and installed in /usr/local/bin
username: domotiga (needs to be changed to the username you're running DomotiGa with) NEVER USE ROOT!

Example domotiga.conf file

# DomotiGa Server Service

description     "DomotiGaServer Service" 
author            "Ron Klinkien <info@domotiga.nl>" 

start on (net-device-up
          and started mysql
          and runlevel [2345])
stop on runlevel [016]

# tell upstart we're creating a daemon
# upstart manages PID creation for you.
respawn
respawn limit 5 5

# configuratio variables

env DOMO_USER=domotiga
env GBX2=/usr/local/bin/gbx2
env GBC2=/usr/local/bin/gbc2
env GBC2_OPTS=-pam

# Execute the program

chdir /opt/domotiga/DomotiGaServer
pre-start exec sudo -H -n -u $DOMO_USER $GBC2 $GBC2_OPTS
exec sudo -H -n -u $DOMO_USER $GBX2 > /dev/null 2>&1

Script details, as you can see in the top part. This script will not start unless the networkcard is running AND mysql AND the current runlevel is 2,3,4 or 5. This has been done on purpose as with Upstart it will start services in parallel unless you give it a clear direction to wait until certain other services are started.

Usage

$ sudo service domotiga start
[sudo] password for <user>:
domotiga start/running, process *****

$ sudo service domotiga stop
[sudo] password for <user>:
domotiga stop/waiting

Logging to Console

This script will make sure there will be no output to console. All console output is piped to /dev/null. DomotiGaServer housekeeping will make sure the log gets written to file as well in the regular logfile directory.

domotiga.conf - Example domotiga.conf (621 Bytes) jrkalf, 12/14/2011 10:19 am