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

Compact-Mode: Adaptercheck Tracking #512

Closed
Apollon77 opened this issue Oct 20, 2019 · 22 comments
Closed

Compact-Mode: Adaptercheck Tracking #512

Apollon77 opened this issue Oct 20, 2019 · 22 comments

Comments

@Apollon77
Copy link
Collaborator

Apollon77 commented Oct 20, 2019

In order to prepare the stable release of js-controller 2.0 and to prevent users having problems with compact mode usage of adapters we want to make sure adapters are really working in compact mode when it is available.

Details about compact mode and how to use it can be taken from https://github.com/ioBroker/ioBroker.js-controller/blob/master/README.md#start-adapter-instances-in-compact-mode

All developers should please use the latest js-controller 2.0 version and check their adapters in compact mode.
Beside the normal functionality please especially test stopping the adapter and starting it again.

After stopping make sure that no state updates happen anymore. Please check your code and make sure that in "on unload" really ALL Timeouts and Intervals are stopped correctly and all used Connections (Network, Serial, Sockets ...) are also closed. Ideally make sure to call the callback when this has finished or check how long all this closing needs (e.g. socket.io closing sometimes needs 1s). By default the adapter is stopped 500ms after calling onUnload independent if callback was already called or not. You can increase that time if needed by setting common.stopTimeout in io-package with an higher value (in ms).

Please also check that multiple instances of your adapter in the same compact group works and that the instances are not mising up somehow.

Please support us to create the best experience for all our users when they want to use the compact mode.
Thank you!

This was referenced Oct 21, 2019
@Zefau
Copy link

Zefau commented Oct 21, 2019

nuki-extended adapter fails with error

startInstance system.adapter.nuki-extended.0: required adapter "web" not found!

io-package.json defines it as dependency:

        "dependencies": [
            {
                "web": ">=1.7.1"
            }
        ],

I have version v2.4.6 installed.

@forelleblau
Copy link

solalog-Adapter:
Gemäss Log werden die 'on.unload' Befehle nicht ausgeführt:
adapter.on('unload', function(callback) { try { clearInterval(polling); adapter.log.info('[END] Stopping solarlog adapter...'); adapter.setState('info.connection', false, true); callback(); } catch (e) { callback(); } });

image

Wie kann das korrigiert werden?

@Apollon77
Copy link
Collaborator Author

@Zefau Can it be multihost and on the host hwhere you want to install hue-extended no web instance is localed? This has nothing to do with Compact mode.

@Zefau
Copy link

Zefau commented Oct 21, 2019

I'm not running a multihost:

image

@Apollon77
Copy link
Collaborator Author

@forelleblau In "unload" it needs to be checked that adapter and also adapter.log still exists ... becaus eit could be already gone when called. I think it runs into the catch because of something no longer existing.moste likely it is the "adapter.log". so maybe write

adapter.log && adapter.log.info('[END] Stopping solarlog adapter...');

@forelleblau
Copy link

forelleblau commented Oct 21, 2019

@Apollon77 thanks, unfortunately this helps only in some (reason unknown) cases. Her two other log-versions beside the one above:

OK-looking[edit: now the right picture]:

image

also not-ok:

image

@Apollon77
Copy link
Collaborator Author

This only about "logging" and sometimes the logs do not come through that close to the end of the process.

@Apollon77
Copy link
Collaborator Author

PS: Der nächste .35 vom Controller lässt den prozess etwas mehr zeit ... dann sollte mehr Logging durhckommen

@Apollon77
Copy link
Collaborator Author

@Zefau Kannst DU bitte mal web auch im compact mode laufen lassen ... in der gleichen gruppe wie hue-extended. geht es dann?

@Zefau
Copy link

Zefau commented Oct 21, 2019

Jo, das funktioniert.

@Apollon77
Copy link
Collaborator Author

kk, fixe ich im controller. Bug gefunden :-)

@Apollon77
Copy link
Collaborator Author

@Zefau Please install js.controller version from GitHub and try again with the "original setting" regarding web. Should now work as long as on same host

@Zefau
Copy link

Zefau commented Oct 22, 2019

Confirmed working

root@bananapim3:~# iobroker compact web.0 status
Adapter supports compact mode:     true
Compact mode enabled for instance: true
Compact group:                     2
root@bananapim3:~# iobroker compact nuki-extended.0 status
Adapter supports compact mode:     true
Compact mode enabled for instance: true
Compact group:                     1
root@bananapim3:~# iobroker compact status
Compact mode for this host is currently enabled

@Apollon77
Copy link
Collaborator Author

Thank you!

@forelleblau
Copy link

@Apollon77 : .35 installiert, Log nun ok. Funktioniert alles. Danke

@angelnu
Copy link

angelnu commented Oct 23, 2019

I have tested that compact works on Linux but I think something is wrong on Windows. I thought it was my adapter (Chromecast) so I tested with sonoff which was updated by @GermanBluefox a couple of days ago:
image

Versions (taken yesterday from Gihub master):

  • controller: 2.0.35
  • sonoff: 2.3.0

Node JS version (installled by iobroker universal Windows installer): v10.16.3

@Apollon77
Copy link
Collaborator Author

WTF all slashes are missing? aaaahhhh ... interesting ... Please install js-controller from GitHub, I changed one place .. working now?

@angelnu
Copy link

angelnu commented Oct 23, 2019

Compact wotks now in Windows @Apollon77 :)

@angelnu
Copy link

angelnu commented Oct 23, 2019

But I think there is a race condition in case there are multiple listeners for "unload". I have multiple listerners (one for each adapter) so each register for the event in order to close its connections. They all get the event (good) but then the adapter logs "terminated" after the first unload event calls the callback:
image

I would expect the adapter to terminate only after all the event callbacks have been received or by force after 500 ms.

On the other hand I do not know if this is "just" a log issue since the adapter seems to still wait for all the callbacks before actually terminating, independently from what the log says...

@Apollon77
Copy link
Collaborator Author

@angelnu Hm. multiple listeners that all call the callback is kind of very unexpected behaviour and currently (also also in the past) not really handled. The expectation is that there is one callback (as usually with callbacks!). We could use "once" there, but then you would get exceptions.

I have adjusted now that all callbacks after the first one are ignored (it's on GitHub), but please know that this means that the first callback triggers the real process "stopping" and latest 500ms after this irst callback everything is gone, especially the DB connections and such.

So in fact : better handle that in your code that you call the unload callback after ALL your internal stuff has executed and make sure to have high enought stopTimeout set in iopackage

@angelnu
Copy link

angelnu commented Oct 23, 2019

Ok, I can implement that a central adapter destroyer calls the mutiple destroyers before calling the callback. I will do that.

Update: Done, now all chromecast instances are destroyed before the adapter terminates. :-)

@mcm1957
Copy link
Contributor

mcm1957 commented Apr 1, 2024

@Apollon77
Is there anything to do based on this issue?
Looks like it is outdated.

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

No branches or pull requests

5 participants