You wrote:
My problem is still unsolved:
- Why does the ZWay service stop working from time to time silently without giving a reason?
- Why was the service not started again. The output of systemctl stayed the same:
For problem 1, if nothing is logged and the z-way-server process randomly exits for no discernable reason, the only idea I have for figuring out why the z-way-server process terminated unexpectedly is to use gdb. Unfortunately, gdb has a pretty steep learning curve which makes this is a difficult problem to solve. To use gdb, stop the z-way-server process and run the following sequence of shell commands as root:
cd /opt/z-way-server; LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./libs:./modules; gdb ./z-way-server
At the gdb prompt, enter "run". When the z-way-server process stops, enter "backtrace" at the gdb prompt to see the frames that were active when the process exited. gdb should also display a reason why the z-way-server process exited. Ideally, gdb will reveal the reason the z-way-server process stopped.
Although not directly related to solving problem 1, your signature shows you are running version Z-Way version 3.2.3. I assume you have good reasons for not upgrading to the latest version. However, I tend to think you'll get more attention from the Z-Way developers if you upgrade to the latest version of Z-Way. Another observation is that no other users on this forum have recently reported a similar problem which suggests there's something unique about your configuration. One of the dangers of the Z-Way software architecture is that it allows users to extend functionality using its javascript engine but it does not protect itself from extensions that could interfere with Z-Way's use of the javascript engine. For example, perhaps you've added an app that's misbehaving, created a javascript virtual device that's misbehaving or accidentally defined a loop in an automation rule.
For problem 2, the solution is much easier. When systemd processes an init.d script, there is no support for restarting a process. One work-around is to run something like monit to detect when the z-way-server process exits and then restart it. IMHO, a preferable solution that's consistent with your approach is to replace the z-way-server init.d script with a service file. Copy something like the following to file /etc/systemd/system/z-way-server.service:
Code: Select all
# systemd configuration for z-way-server
[Unit]
Description=RaZberry Z-Way server
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/opt/z-way-server/z-way-server --daemon --pidfile=/var/run/z-way-server.pid
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory=/opt/z-way-server
Type=simple
PIDFile=/var/run/z-way-server.pid
Restart=always
RestartSec=120
User=root
Group=root
[Install]
WantedBy=multi-user.target
It takes a few steps to use the service file, as follows:
1. Stop the current z-way-server process. Run ps -ef | grep z-way to confirm.
2. Move /etc/init.d/z-way-server to /etc/init.d/z-way-server-OLD. This makes it easy to revert back to the init.d method.
3. Create the file /etc/systemd/system/z-way-server.service as shown above.
4. Run: systemctl daemon-reload
5. Run: systemctl start z-way-server. Run systemctl status z-way-server to confirm.
6. To make the z-way-server service start automatically, run: systemctl enable z-way-server
Note that I have not done any testing on the service script; proceed as you see fit.