Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd target for openHAB REST service availibility #138

Open
pfink opened this issue Jan 5, 2019 · 5 comments
Open

Add systemd target for openHAB REST service availibility #138

pfink opened this issue Jan 5, 2019 · 5 comments

Comments

@pfink
Copy link

pfink commented Jan 5, 2019

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 to network-online.target). I'd suggest openhab2-rest.target. Anyhow, I have no clue how this can be done :/

@BClark09
Copy link
Member

BClark09 commented Jan 25, 2019

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?

@pfink
Copy link
Author

pfink commented Jan 25, 2019

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?

@pfink
Copy link
Author

pfink commented Jan 25, 2019

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).

@BClark09
Copy link
Member

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"

@BClark09
Copy link
Member

Note: that due to the problem described in openhab/openhabian#792 the above commadn wont work without providing a password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants