Open pfink opened 5 years ago
We might be able to implement a shell script which has its own target unit file associated with it.
The script would poll http://localhost:$OPENHAB_HTTP_PORT/rest/
for a 200 response every 5 or so seconds?
Sounds reasonable! But we have to find a solution to prevent this from running in case no REST bundle is installed. Maybe it should first poll openhab-cli and only start to poll REST if the bundle is actually installed? I'm just not sure if bundle:list
shows reliable results during startup phase... But maybe there is another possibility, e.g. check a config file?
Other idea, if no automatic detection is possible, would be to prepare this systemd service/target, but keep it disabled by default (so that the user just enable it if needed).
A service can be setup to retry a certain amount of times before stopping completely. Perhaps we can check to see if the bundle is active using:
openhab-cli console bundle:list | grep "REST Interface Bundle"
Note: that due to the problem described in https://github.com/openhab/openhabian/issues/792 the above commadn wont work without providing a password.
Some other processes may depend on the availability of openHAB's REST service. If they depend on
openhab2.service
, this won't work because even when openhab2.service is started, REST service needs some extra time to be available. It would be good to setup a systemd target that other services can depend on (similar tonetwork-online.target
). I'd suggestopenhab2-rest.target
. Anyhow, I have no clue how this can be done :/