openhab-scripters / openhab-helper-libraries

Scripts and modules for use with openHAB
Eclipse Public License 1.0
88 stars 69 forks source link

000_startup_delay run for all languages #277

Closed rkoshak closed 4 years ago

rkoshak commented 4 years ago

I'm seeing the following and I'm wondering if it's necessary or if there is a way to avoid it.

Let's say all I've done is install the Rule Engine. Since JS comes with Java, immediately 000_startup_delay.js is run which blocks startup for 30 seconds. So far so good.

But I'm only using Python. So I enable Jython and now both 000_startup_delay.js and 000_startup_delay.py end up running, doubling the startup delay from 30 seconds to a minute. Presumably if 30 seconds is enough for one language, it's enough for two. I'd also assume that for each additional language added (Groovy is the only one right now) an additional 30 seconds would be added to the delay.

Is this necessary? Since you always get JavaScript whether you plan on using it or not, maybe the .py and Groovy versions of the delay script are not needed.

Is there some side effect I'm unaware of?

5iver commented 4 years ago

I've been running for weeks without any startup delay scripts, in preparation for removing all of them. But yes, removing all but the JS would work too. There is no other side effect.

rkoshak commented 4 years ago

If you will be removing them all anyway I'll go ahead and close this. No need to remove them little by little in multiple PRs.

Thanks!

5iver commented 4 years ago

Lets keep this open until a PR is out. I have not had any issues running without the startup delay, but I am not running any DSL rules, so that may affect things. Could you test this too? Hopefully something changed for the better in OH!

To keep backwards compatibility, the startup delay scripts can't just be removed. I think the best approach would be to add this to each script:

1) Check if flag has been set by another script and exit if it has been set 2) Check OH version and store as a variable in a ScriptExtension (I can see this being useful for other things and in the future should be included in the default script scope) 3) If the OH version is old enough to require it, run the startup delay 4) Set a startup_delay_has_run variable in a ScriptExtension and exit

ScriptExtensions can be used as a mechanism by which data can be read/modified by scripts of different languages.

rkoshak commented 4 years ago

I did a quick and dirty test by renaming the scripts and I didn't see any errors. But I too no longer have any Rules DSL files so can't test if there is an interaction there.

5iver commented 4 years ago

All startup delay scripts were removed in #336.