Openhab 1.8 crash - how to auto restart?

I have 1.8 installed on my ubuntu machine. This morning something happened and openhab just quit. I checked the openhab logs, the system, dmesg, all over. Nothing looked out of the ordinary. It just quit. I restarted it and all was happy again. Very odd, but this poses the question for me. How can I have openhab just restart? It looks like upstart has a respawn option, but installing from the deb (which I love) uses init.d.

Anyone have any suggestions? Hoping there is a clean easy way without having to install more complicated systems on top of it just to restart.

Maybe this can help you out:

Continuing the discussion from Automatic reboot at zwave stick problem:

1 Like

I have also implemented a watchdog, to restart openHAB if there are no new updates comming via z-wave. However this watchdog does not help, when openhab freezes with /dev/ttyACM0: No such file or directory in a log. On my machine it requires reboot.

I will check if usb reset would help, but it is not easy to test, as the error condition (luckily) appears really rarely.

Below is C code to reset usb bus given as an command line argument by sending USBDEVFS_RESET to the special file. I use it to clear stalled UPS monitoring connection.
Usage usbreset /dev/bus/usb/001/003 where parameters after usb denote bus and device obtained from lsusb.

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>

int main(int argc, char **argv)
{
    const char *filename;
    int fd;
    int rc;

    if (argc != 2) {
        fprintf(stderr, "Usage: usbreset device-filename\n");
        return 1;
    }
    filename = argv[1];

    fd = open(filename, O_WRONLY);
    if (fd < 0) {
        perror("Error opening output file");
        return 1;
    }

    printf("Resetting USB device %s\n", filename);
    rc = ioctl(fd, USBDEVFS_RESET, 0);
    if (rc < 0) {
        perror("Error in ioctl");
        return 1;
    }
    printf("Reset successful\n");
    close(fd);
    return 0;
}

Oddly enough the last entries in my log are related to losing connection with z-wave stick. Didn’t realize that was an issue others have been having.

I have started working on some solutions thank you!!!