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

Question: ruby console / irb in production? #148

Open
doits opened this issue Sep 17, 2023 · 3 comments
Open

Question: ruby console / irb in production? #148

doits opened this issue Sep 17, 2023 · 3 comments

Comments

@doits
Copy link
Contributor

doits commented Sep 17, 2023

Is there a method to open an interactive console (like binding.irb) in the openhab production environment?

I found https://github.com/openhab/openhab-jruby/blob/main/docs/testing.md#irb but it looks like it is meant for the testing instance only? E.g. all the gems (needed to run it) and jruby must be installed already or provided by openhab since otherwise my rules wouldn't run or not?

I'd like to test stuff like MyItem.changed_since?(...) inside an interactive console and evaluate the output. (I know I could write rules that eg output it every second to the logs etc. but I feel an interactive console would be neater!).

Is this possible?

@ccutrer
Copy link
Contributor

ccutrer commented Sep 17, 2023

I've long thought about somehow hosting an IRB session inside a running openHAB instance, but never implemented such a thing. What you linked to is the closest thing, and in some ways even better (and in the same ways even worse). It does require you to install JRuby separately from openHAB, but then it loads up your actual openHAB config into a detached, limited instance of openHAB, allowing you to interact with your items without accidentally annoying your spouse by having them actually forward to linked channels! I use this quite often when writing a new feature for the helper library to explore what's actually possible against openHAB's classes.

@ccutrer
Copy link
Contributor

ccutrer commented Sep 17, 2023

Perhaps https://github.com/pry/pry/wiki/Remote-sessions will just work? You'd need to add the pry-remote gem inside OpenHAB, and then have a separate Ruby installation in order to connect to it (which can be any Ruby version, as I understand). So still a bit more work than IRB hosted through say openhab-cli, but at least it would actually be running inside your prod openHAB instance.

@ccutrer
Copy link
Contributor

ccutrer commented Sep 17, 2023

Looks like IRB itself is working towards being able to easily do this: ruby/irb#672

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