Page 1 of 2

Automatic restart

Posted: 04 Apr 2017 22:39
by Isaksson
Hello.
Sometimes my z-way-server crashes, it could be hour, days or month between the crashes so its hard to know when it will happen and it is always frustrating when it occurs because you will notice it when the lights not comes on or when you try to control something and it does not work.

I have no solution for the crashes but I have a workaround that will restart the service when it crashes.
I just installed this tonight and I have verified it by stopping the service and I see no reason that this will fail in the long run.

Simple instruction on how I did this.

Install monit:
sudo apt-get install monit

Modify the config to change the check interval(optional step):
sudo nano /etc/monit/monitrc
set daemon 120
enable monit webserver at port 2812 with login username admin and password monit(optional step):
set httpd port 2812 and
allow admin:monit

Save the file and create a new config file with the following content:
sudo nano /etc/monit/conf.d/z-way-server

check process z-way-server with match z-way-server
start program = "/etc/init.d/z-way-server start"
stop program = "/etc/init.d/z-way-server stop"

save the file

last command to initialize monit with new config:
sudo monit reload

Now monit will start z-way-server if it does not run.
If you have enabled the web server then you could monitor this at http://ip:2812

Re: Automatic restart

Posted: 04 Apr 2017 23:18
by micky1500
Thanks Isaksson
Will be installing monit tomorrow.
Since 2.3.0 I have noticed 3 times now that the z-way server had shut itself down, nothing in the normal log to explain the reason.
restart of z-way server and it works again for a long time.
Guessing the z-way watchdog monitor has got broken in this last update..

And nice instructions on how to setup monit :)

Re: Automatic restart

Posted: 04 Apr 2017 23:37
by Isaksson
Thanks :)

I hope you will find it useful.

And about the instructions, there is so many post with instructions where the authors have left out many steps that they assume the user should know and that is just bad ;)
The meaning with a post like this is that anyone with the knowledge to install z-way could install this without any special skills.

Re: Automatic restart

Posted: 04 Apr 2017 23:45
by Isaksson
Just have to say that I have already been "saved" by this.
Log file is great to keep track of how often this happens.

Code: Select all

[MSK Apr  4 21:47:46] error    : 'z-way-server' process is not running
[MSK Apr  4 21:47:46] info     : 'z-way-server' trying to restart
[MSK Apr  4 21:47:46] info     : 'z-way-server' start: /etc/init.d/z-way-server
[MSK Apr  4 21:49:46] info     : 'z-way-server' process is running with pid 16666
You will find the log file in this location by default:

/var/log/monit.log

Re: Automatic restart

Posted: 05 Apr 2017 09:11
by Z-Wave Support
Hello Isaksson,

can you help us, please.

Please make a log with the following guidance and send this to support@zwave.eu

1. open PuTTY (SSH Client)
2. stop Z-Way-Server: “$ sudo /etc/init.d/z-way-server stop”
3. switch to the Z-Way-Server directory: “$ cd /opt/z-way-server”
4. start Z-Way-Server with gdb debugger (should be installed): “$ LD_LIBRARY_PATH=./libs gdb ./z-way-server”
5. type in ‘r’ for start
6. confirm one time with ‘c’ for continue
7. Z-Way-Server is starting…

When the server crashes, a message like this one appears:

“Program received signal SIGINT, Interrupt.
0xb6403360 in nanosleep () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.”

with an input prompt.
There you have to type in: ‘info thread’ and copy the log, then type in ‘bt’ and copy this log aswell.

After this, you can exit the debugger with ‘q’ for quit and restart it with: “$ sudo /etc/init.d/z-way-sever restart”

If the port 8083 is still occupied, then please stop the Z-Way-Server manually with: “$ sudo killall -9 z-way-server”.

(Addition:)

Some additional commands for the debugger:

If you log on as a root user, then you should not receive error messages. Use: “$sudo su” and then start this with the debugger.

The best would be, to do that within one screen session.
1. “$screen” (you have to install that eventually, you can do this with: “$sudo apt-get install screen”)
2. $sudo su (root user)
3. and then please follow the instructions for the gdb procedure…

The advantage of this, is that this can be active in the background.
You can log out of the session with: “$detach” and when you reconnect through SSH, then you will be logged in at the appropriate point.
You can alternatively keep that window open.
“$exit” will end the screen session within the session.

Here is more about that: https://wiki.ubuntuusers.de/Screen/.

Thank you
Z-Wave Support

Re: Automatic restart

Posted: 05 Apr 2017 14:46
by Isaksson
Hello.
Sure, I have now turned of the automatic restart of service and I am now running it in gdb mode.

Re: Automatic restart

Posted: 02 Aug 2017 18:10
by ThePostman
It would be nice to see the debug instructions in the FAQ. Once in a while I have to search the forum for these instructions.

Re: Automatic restart

Posted: 08 Aug 2021 19:47
by luhrern
Monit installed according to Isakssons' explanation as per 04 Apr 2017 21:39.

However if I choose to reboot me Rasepberry PI, I need to restart the Monit program with "sudo Monit reload", any way this could be done in teh program when teh Raspeberry Pi boots?

Re: Automatic restart

Posted: 10 Aug 2021 23:43
by micky1500
Are you sure it's not running ?
Can you get the monitor page at http://ip:2812
or check the log file at \var\log\monit.log

I have monit 5.25.2 and it automatically starts after a reboot.
If you don't have a file at \etc\init.d\monit
Then try to reinstall it.

Re: Automatic restart

Posted: 13 Aug 2021 15:01
by luhrern
Dear micky1500

I didi a monit -V and got the message that I had "version 5.20.0".

Did a "sudo apt install -y monit" , but get a message that I have the newest version 5.20.0.