Project

General

Profile

DomotiGaServer

Usage

Very new is the DomotiGaServer project.
It's DomotiGa without the GUI, you can create an executable by loading it's project into Gambas IDE and choose Project -> Make -> Executable.
And save it in your domotiga directory.

Then run it from a shell with:

$ cd ~/domotiga
$ ./DomotiGaServer.gambas
2009/11/11 20:02:34   ---- Program Restart ----
2009/11/11 20:02:34 Starting [[DomotiGaServer]] V0.1.172 last updated on 2009-11-11 at 20:02:33
2009/11/11 20:02:34 Running on server (pid 11779) as user ron (id 1000) with language en_US.UTF-8
2009/11/11 20:02:34 Program base directory is '/home/ron/domotiga/'.
2009/11/11 20:02:34 Database settings are loaded from 'domotiga.conf'.
2009/11/11 20:02:34 Active logfiles are 'server-main-2009-11.log', 'server-speak-2009-11.log' and 'server-debug-2009-11.log'.
2009/11/11 20:02:34 Running on Gambas version 2.17.0
2009/11/11 20:02:34 Server uptime is  20:02:34 up 10 days, 8:41, 4 users, load average: 0.22, 0.10, 0.0
2009/11/11 20:02:34 Checking directory structure ...
2009/11/11 20:02:34 Connecting to database ...
2009/11/11 20:02:34 Loading modules ...
...
...

It will output the normal log text to stdout.

You can also give it an -d argument and it will start as a daemon, detached from the command line.
But I haven't tested that enough, had an issue with the log buffers being written to the logfiles correctly.

$ ./DomotiGaServer.gambas -d

You can stop the daemon like this, until we created a decent init.d script.

$ ps aux|grep gb
ron      11657 18.0  0.0  21676  2852 ?        Rs   19:57   0:02 gbr2 ./DomotiGaServer.gambas -d
ron      11674  0.0  0.0   3036   804 pts/2    S+   19:58   0:00 grep --color=auto gb

$ kill 11657

You can monitor DomotiGaServer by looking at it's logfiles, those are written in DomotiGa's normal logs directory and are called server-[main|debug|speak]-<date>.log.

Until we have build a web gui to change the program settings, you have to use the normal DomotiGa program to do this.
From version 0.1.173 you can start the DomotiGa program in client/server mode.
Just change it's domotiga.conf to use the servers mysql and xmlrpc services.

Some notes about client/server setup between 2 different machines;
Default mysqld is connected to localhost only, so you cannot connect to it from other hosts.

Change the config file:

$ sudo vi /etc/mysql/my.conf

#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address            = 127.0.0.1
bind-address            = 0.0.0.0

Restart mysql server.

$ sudo /etc/init.d/mysql restart

Now you have to grant the domotiga user access to the database.

$ mysql -u root -p
Enter password: 
Welcome to the [[MySQL]] monitor.  Commands end with ; or \g.
Your [[MySQL]] connection id is 132
Server version: 5.1.37-1ubuntu5 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT ALL ON domotiga.* TO domouser@'%' IDENTIFIED BY 'kung-fu';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

This is also a nice moment to change your mysql password from the default to your own!

MySQL server has gone away error

You have to make this config setting if you want to use domotiga client/server, this prevents the mysql connection being closed if the client doesn't send anything for a few hours (which happens during the night)

Change wait_timeout parameter value to prevent database connection lost.
Add this to the [mysqld] section of the config file

$ sudo vi /etc/mysql/my.conf
wait_timeout            = 2147483

Restart the mysql process after this.

$ sudo /etc/init.d/mysql restart

You have to make sure to stop/restart DomotiGaServer after this.

System Init Script

Egon build a system init script for Fedora 11/12, it probably works on Redhat too.
(The Server-Upstart page contains information for an Upstart script for Ubuntu Linux or other systems that use Upstart as system init.)

Copy tools/domotiga.fedora script to system:

$ sudo cp tools/domotiga.fedora /etc/init.d/domotiga
$ cd /etc/init.d

Edit basedir path to reflect your domotiga location:

$ sudo vi domotiga
BASEDIR=/opt/domotiga

Create a settings file so it starts in daemon mode:

sudo vi /etc/sysconfig/domotiga
OPTIONS="-d" 

Add script to startup configuration:

chkconfig --add domotiga

You can now start and stop DomotiGaServer with:

"service domotiga start" en "service domotiga stop".

Related Resources

    Updated by: jrkalf, Updated over 7 years ago
    Access count: 76539 since 2011-08-25

    Attached Files

    Also available in: PDF HTML TXT