Skip to content

Mirroring: second instance of script. #905

Closed

Description

@ticaki

Hallo,

wenn ich mein großes Skript mit einem externen Editor bearbeite und dann über netatalk auf den Raspberry Iobroker Server speichere bekomme ich gelegentlich eine unsichtbare 2. Instance dieses Skriptes.
Aufgefallen ist mir das wegen folgenden Logauszug:
`
2021-10-24 12:29:26.708 - info: javascript.0 (18514) Stop script script.js.Messages.dwd_uwz_nina_script
2021-10-24 12:29:47.485 - info: javascript.0 (18514) Start javascript script.js.Messages.dwd_uwz_nina_script
2021-10-24 12:29:47.889 - info: javascript.0 (18514) script.js.Messages.dwd_uwz_nina_script: registered 8 subscriptions and 1 schedule
2021-10-24 12:36:32.442 - info: javascript.0 (18514) script.js.Messages.dwd_uwz_nina_script: Add DWD warning to database. headline: Amtliche WARNUNG vor FROST
2021-10-24 12:49:48.308 - info: javascript.0 (18514) script.js.Messages.dwd_uwz_nina_script: Add UWZ/DWD warning to database. id: javascript.0.wetterwarnung.data.dwd.warning.object headline: Amtliche WARNUNG vor FROST
2021-10-24 12:56:32.429 - info: javascript.0 (18514) script.js.Messages.dwd_uwz_nina_script: Add DWD warning to database. headline: Amtliche WARNUNG vor FROST

`

Ich hatte 'Add DWD warning' in 'Add UWZ/DWD' warning' geändert. Das Problem lässt sich aktuell durch einen neustart des Javascript Adapters beheben.

iobroker auf dem aktuellen Stand vom 24.10 latest
Node: v12.22.6

Activity

  1. Apollon77 commented on Oct 24, 2021

    @Apollon77
    Contributor

    Wie sieht das Skript denn aus und was tut es? Passiert das gleiche wenn Du per Admin JavaScript UI das Script restartest?

    Je nachdem was das Script tut braucht man ggf https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#onstop

  2. ticaki commented on Oct 25, 2021

    @ticaki
    Author

    Es ist dieses Skript: https://github.com/ticaki/DWD-UWZ-NINA-Pushwarnungen-iobroker/blob/master/dwd_uwz_nina_script_with_DWDUWZ_inside_ALPHA.js

    Nein das passiert nicht im Admin. Nachfolgend hab ich das Skript über externen Editor einen Logeintrag in einem Interval (10 Sekunden) 4 mal verändert und anschließend admin dahinter geschrieben und es im Skripteditor ebenfalls 4 mal verändert neugestartet:

    `

    javascript.0 2021-10-25 10:38:42.718 info script.js.Messages.dwd_uwz_nina_script: instance 2
    javascript.0 2021-10-25 10:38:35.246 info script.js.Messages.dwd_uwz_nina_script: instance 3
    javascript.0 2021-10-25 10:38:32.718 info script.js.Messages.dwd_uwz_nina_script: instance 2
    javascript.0 2021-10-25 10:38:25.245 info script.js.Messages.dwd_uwz_nina_script: instance 3
    javascript.0 2021-10-25 10:38:22.718 info script.js.Messages.dwd_uwz_nina_script: instance 2
    javascript.0 2021-10-25 10:38:16.152 info Stop script script.js.Messages.dwd_uwz_nina_script
    javascript.0 2021-10-25 10:38:15.245 info script.js.Messages.dwd_uwz_nina_script: instance 3
    javascript.0 2021-10-25 10:38:12.717 info script.js.Messages.dwd_uwz_nina_script: instance 2
    javascript.0 2021-10-25 10:38:11.212 info script.js.Messages.dwd_uwz_nina_script: instance 8 admin
    javascript.0 2021-10-25 10:38:05.245 info script.js.Messages.dwd_uwz_nina_script: instance 3
    javascript.0 2021-10-25 10:38:02.716 info script.js.Messages.dwd_uwz_nina_script: instance 2
    `

    ich nutze
    const axios = require('axios');

  3. Apollon77 commented on Oct 25, 2021

    @Apollon77
    Contributor

    Das mirrorng macht nichts anderes als das objekt ändr was eine restart auslöst. Das Skript ist recht komplex und so kann es zu themen kommen wie "während axios auf antwort wartet beendest Du das skript ... das axios response kommt aber und dann werden ggf setTimeout neue dinge gestartet und schon beendet es sich nicht

  4. ticaki commented on Oct 25, 2021

    @ticaki
    Author

    Ich verstehe das Problem, sehe aber keine Lösung die sicher ist. Axios wird von Intervall aufgerufen, wäre schedule dann besser dafür geeignet?

  5. Apollon77 commented on Oct 25, 2021

    @Apollon77
    Contributor

    Nein, du musst am besten die oben genannte onStop" nutzen und die ggf eine variable setzen die sicherstellt das zb wenn ein axios call "zurück kommt" aber diese variable gesetzt ist der code nicht weiterläuft
    also etwas wi "stopped = true" und dann nach axiios ein "if stopped return;" und kene neue sachesetzen.

    An sich werden intervalle (die die der Skript-Adapter erkennen kann) beendet ... kann sein das dieses interfvall komisch ist. also ggf auch das interval in onStop beenden

  6. ticaki commented on Oct 25, 2021

    @ticaki
    Author

    Das sieht in Auszügen so aus: ...

        if (enableInternDWD && !internalDWDInterval) {
            await getDataFromServer(first);
            internalDWDInterval = setInterval(getDataFromServer, intervalMinutes * 60 * 1000);
        }
    
    async function getDataFromServer(first) {
        if (enableInternDWD) await _getDataFromServer(internDWDUrl, DWD, first);
        if (enableInternUWZ) await _getDataFromServer(internUWZUrl, UWZ, first);
        async function _getDataFromServer(url, m, first) {
            for (var i = 0; i < dwdWarncellId.length; i++) {
                await axios.get(url)
    
    

    Ich nehme deine Lösung. Wenn globale Variablen pro Instanz einzigartig sind ist das kein Thema. Danke.

    EDIT: aber im letzten Log Auszug hab ich einfach an den Anfang ein setInterval(function(){log('xxx'),1000}) gesetzt der wurde auch nicht beendet und da ist nix komisches dran. :)

  7. ticaki commented on Oct 25, 2021

    @ticaki
    Author

    Hab damit noch etwas rumgespielt und das Problem ist das die Skripte 2 x gestoppt und dann 2 x gestartet werden. Betrifft für mich jedes Skript das ich von extern verändere. Und bei dem 2 x stoppen bleibt immer eines über.
    (die Zahl ist Math.random())

    javascript.0 | 2021-10-25 21:22:37.733 | info | script.js.Messages.Battery: 0.5001161828182787
    -- | -- | -- | --
    javascript.0 | 2021-10-25 21:22:37.705 | info | script.js.Messages.Battery: 0.009880656790089315
    javascript.0 | 2021-10-25 21:22:35.733 | info | script.js.Messages.Battery: registered 2 subscriptions and 0 schedules
    javascript.0 | 2021-10-25 21:22:35.732 | info | script.js.Messages.Battery: 0.5001161828182787
    javascript.0 | 2021-10-25 21:22:35.709 | info | Start javascript script.js.Messages.Battery
    javascript.0 | 2021-10-25 21:22:35.706 | info | script.js.Messages.Battery: registered 2 subscriptions and 0 schedules
    javascript.0 | 2021-10-25 21:22:35.705 | info | script.js.Messages.Battery: 0.009880656790089315
    javascript.0 | 2021-10-25 21:22:35.646 | info | Start javascript script.js.Messages.Battery
    javascript.0 | 2021-10-25 21:22:35.630 | info | Stop script script.js.Messages.Battery
    javascript.0 | 2021-10-25 21:22:35.619 | info | Stop script script.js.Messages.Battery
    
    
  8. reopened this on Oct 25, 2021
  9. Apollon77 commented on Oct 26, 2021

    @Apollon77
    Contributor

    Kannst Du javascript-.Adapzter mal in Debug Log starten und davon das Log posten bitte?

  10. ticaki commented on Oct 28, 2021

    @ticaki
    Author

    Bitte schön:

    javascript.0 | 2021-10-29 00:57:34.464 | info | Start javascript script.js.Messages.dwd_uwz_nina_script
    -- | -- | -- | --
    javascript.0 | 2021-10-29 00:57:34.459 | info | script.js.Messages.dwd_uwz_nina_script: registered 8 subscriptions and 1 schedule
    javascript.0 | 2021-10-29 00:57:34.062 | info | Start javascript script.js.Messages.dwd_uwz_nina_script
    javascript.0 | 2021-10-29 00:57:34.034 | info | Stop script script.js.Messages.dwd_uwz_nina_script
    javascript.0 | 2021-10-29 00:57:34.030 | info | Stop script script.js.Messages.dwd_uwz_nina_script
    javascript.0 | 2021-10-29 00:57:33.950 | debug | Update script script.js.Messages.dwd_uwz_nina_script in DB
    javascript.0 | 2021-10-29 00:57:33.946 | debug | File /opt/iobroker/Scripts/Messages/dwd_uwz_nina_script.js change
    javascript.0 | 2021-10-29 00:57:33.946 | debug | Update script script.js.Messages.dwd_uwz_nina_script in DB
    javascript.0 | 2021-10-29 00:57:33.941 | debug | File /opt/iobroker/Scripts/Messages/dwd_uwz_nina_script.js change
    
  11. Apollon77 commented on Oct 29, 2021

    @Apollon77
    Contributor

    Ok, how you change the file because the adapter recognize two filechanges as you see with a delay of 5ms to each other

  12. ticaki commented on Oct 29, 2021

    @ticaki
    Author

    I use Atom (https://atom.io/) over netatalk from a mac (High Sierra and Big Sur) to a Raspberry Pi 4.

  13. stale commented on Apr 16, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.
    Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

  14. stale commented on Apr 27, 2022

    @stale

    This issue has been automatically closed because of inactivity. Please open a new issue if still relevant and make sure to include all relevant details, logs and reproduction steps. Thank you for your contributions.
    Dieses Problem wurde aufgrund von Inaktivität automatisch geschlossen. Bitte öffnet ein neues Issue, falls dies noch relevant ist und stellt sicher das alle relevanten Details, Logs und Reproduktionsschritte enthalten sind. Vielen Dank für Eure Unterstützung.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions