z-way-server daemon with ubuntu 12.04

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
dschonac
Posts: 12
Joined: 05 Feb 2015 17:32

z-way-server daemon with ubuntu 12.04

Post by dschonac »

Hello everyone,

i have been trying to install z-way-Server on voyage-linux on an Alix-3d board. Since this does not seem to be possible, i now switched to ubuntu 12.04 precise. I edited the install script to use the right libraries, and fixed the Serial port issue.

I am able to use the z-way-Server by launching it manually:

Code: Select all

cd /opt/z-way-Server && ./z-way-Server
I get a warning about curl 7.22.0 DNS-timeout bug, but i can access ip:8083 and do z-way stuff (include, Switch on/off etc., everything works fine).
However, the deamon does not work. By uncommenting "#> /dev/null 2>&1" i learned that ubuntu 12.04 does not support "deamon-start-stop --no-close", so no PID-file is created. I tried to edit this, and ubuntu now creates the PID-file, but i still get the "error handling data from Server"-message again.

In conclusion the z-way-Server only works when i start it manually. Since i want it to start at boot, this is not a suitable Option.

Naturally i tried installing ubuntu 14.04, but i dont get it to work on the Alix-Board.

Can anyone help me to edit the z-way-Server script (/etc/init.d/z-way-Server) so that it works with ubuntu 12.04?
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: z-way-server daemon with ubuntu 12.04

Post by pofs »

Are you sure the script is running in the correct directory? Z-wave binding uses relative paths, so running in the wrong directory will result in module startup failure and error above.
dschonac
Posts: 12
Joined: 05 Feb 2015 17:32

Re: z-way-server daemon with ubuntu 12.04

Post by dschonac »

What exactly do you mean by correct directory?
Z-Way is running in /opt/z-way-server/
The daemon script is located in /etc/init.d/
I can use z-way, but only if i start it manually by going into /opt/z-way-server and executing ./z-way-server.

This is the regular init.d script to start the daemon:

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:		  z-way-server
# Required-Start:	
# Required-Stop:	 
# Default-Start:	 2 3 4 5
# Default-Stop:	  0 1 6
# Short-Description: RaZberry Z-Wave service
# Description:	   Start Z-Way server for to allow Raspberry Pi talk with Z-Wave devices using RaZberry
### END INIT INFO

# Description: RaZberry Z-Way server
# Author: Yurkin Vitaliy <aivs@z-wave.me>

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=z-way-server
DAEMON_PATH=/opt/z-way-server
PIDFILE=/var/run/$NAME.pid

# adding z-way libs to library path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/z-way-server/libs

case "$1" in
  start)
	echo -n "Starting z-way-server: "
	start-stop-daemon --start  --pidfile $PIDFILE --make-pidfile  --background --no-close --chdir $DAEMON_PATH --exec $NAME > /dev/null 2>&1
	echo "done."
	;;
  stop)
	echo -n "Stopping z-way-server: "
	start-stop-daemon --stop --quiet --pidfile $PIDFILE
	rm $PIDFILE
	echo "done."
	;;
  restart)
	echo "Restarting z-way-server: "
	sh $0 stop
	sleep 10
	sh $0 start
	;;
  save)
	echo "Saving z-way-server configuration"
	PID=`sed s/[^0-9]//g $PIDFILE`
	/bin/kill -10 $PID
	;;
  *)
	echo "Usage: /etc/init.d/z-way-server {start|stop|restart|save}"
	exit 1
	;;
esac
exit 0
By uncommenting "# > /dev/null 2>&1" i get the following error/Output:

Code: Select all

Starting z-way-server: start-stop-daemon: unrecognized Option '--no-close'
If i delete the '--no-close' Parameter, i get the following Output:

Code: Select all

Starting z-way-server: start-stop-daemon: unable to stat z-way-server (No such file or Directory)
So i deleted the '--chdir' Attribute, the line now looks like this:

Code: Select all

start-stop-daemon --start  --pidfile $PIDFILE --make-pidfile  --background --exec $DAEMON_PATH/$NAME # > /dev/null 2>&1
With this line i can start the daemon, no error messages.
BUT: i get the "Error handling data from Server"-Error when i access the webinterface.
The same happens when i try to start z-way-server like this

Code: Select all

/opt/z-way-server/z-way-server
The only way to get it working properly is with these commands:

Code: Select all

cd /opt/z-way-server && ./z-way-server
How do i have to modify the init.d-script to start z-way properly?
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: z-way-server daemon with ubuntu 12.04

Post by pofs »

--chdir is mandatory, so process will be started in the correct directory. When you delete it, it is obviously running in the wrong one and cannot find necessary files and modules.
Look into man for start-stop-daemon on your system, maybe it has some other parameter to do that.

BTW, why not updating to the recent system? 12.04 is rather outdated now.
dschonac
Posts: 12
Joined: 05 Feb 2015 17:32

Re: z-way-server daemon with ubuntu 12.04

Post by dschonac »

Hello,
thank you for your reply!

As is said before, i tried updating to 14.04, but i don't get it to work on my Alix boards. I am guessing it has something to do with the kernel, since 14.04 need some kind of PAE-support from the CPU (http://wiki.ubuntuusers.de/Alix/CF-Boot ... Bootloader).

But i successfully edited the init.d script, now everything is running fine. For anyone who is running into the same problems, here is my edited script:

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:		  z-way-server
# Required-Start:	
# Required-Stop:	 
# Default-Start:	 2 3 4 5
# Default-Stop:	  0 1 6
# Short-Description: RaZberry Z-Wave service
# Description:	   Start Z-Way server for to allow Raspberry Pi talk with Z-Wave devices using RaZberry
### END INIT INFO

# Description: RaZberry Z-Way server
# Author: Yurkin Vitaliy <aivs@z-wave.me>

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=z-way-server
DAEMON_PATH=/opt/z-way-server
PIDFILE=/var/run/$NAME.pid

# adding z-way libs to library path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/z-way-server/libs

case "$1" in
  start)
	echo -n "Starting z-way-server: "
	start-stop-daemon --start  --pidfile $PIDFILE --make-pidfile  --background  --chdir /opt/z-way-server/ --exec z-way-server > /dev/null 2>&1
	echo "done."
	;;
  stop)
	echo -n "Stopping z-way-server: "
	start-stop-daemon --stop --quiet --pidfile $PIDFILE
	rm $PIDFILE
	echo "done."
	;;
  restart)
	echo "Restarting z-way-server: "
	sh $0 stop
	sleep 10
	sh $0 start
	;;
  save)
	echo "Saving z-way-server configuration"
	PID=`sed s/[^0-9]//g $PIDFILE`
	/bin/kill -10 $PID
	;;
  *)
	echo "Usage: /etc/init.d/z-way-server {start|stop|restart|save}"
	exit 1
	;;
esac
exit 0
Post Reply