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

Schedule in einem Skript kann nicht gestoppt werden bei Skript Stop #1102

Closed
Negalein opened this issue Aug 18, 2022 · 8 comments · Fixed by #1170
Closed

Schedule in einem Skript kann nicht gestoppt werden bei Skript Stop #1102

Negalein opened this issue Aug 18, 2022 · 8 comments · Fixed by #1170

Comments

@Negalein
Copy link

Script lässt sich nicht stoppen.

hier wurde das Script gestoppt und wieder gestartet. Da gibt es schon die 1. Error-Meldung.

javascript.0 2022-08-18 17:36:47.136	info	Start javascript script.js.Wetter.Wetter_to_FTP
javascript.0 2022-08-18 17:36:44.540	error	Error by canceling scheduled job "<Anonymous Job 23 2022-08-18T12:57:51.743Z>"
javascript.0 2022-08-18 17:36:44.539	info	Stop script script.js.Wetter.Wetter_to_FTP

Und hier dann doppelt im JS und Puppeteer

javascript.0 2022-08-18 17:39:03.369	error	script.js.Wetter.Wetter_to_FTP: Error on upload: Error: Command failed: wput -nc /opt/iobroker/iobroker-data/files/0_userdata.0/wetterstation.png ftp://xxxxx:xxxxx@www37.world4you.com ()
javascript.0 2022-08-18 17:39:03.184	error	script.js.Wetter.Wetter_to_FTP: Error on upload: Error: Command failed: wput -nc /opt/iobroker/iobroker-data/files/0_userdata.0/wetterstation.png ftp://xxxxx:xxxxx@www37.world4you.com ()
javascript.0 2022-08-18 17:39:03.157	info	script.js.Wetter.Wetter_to_FTP: exec: wput -nc /opt/iobroker/iobroker-data/files/0_userdata.0/wetterstation.png ftp://xxxxx:xxxxx@www37.world4you.com
puppeteer.0  2022-08-18 17:39:03.056	debug	Write file to "wetterstation.png"
javascript.0 2022-08-18 17:39:02.884	info	script.js.Wetter.Wetter_to_FTP: exec: wput -nc /opt/iobroker/iobroker-data/files/0_userdata.0/wetterstation.png ftp://xxxxx:xxxxx@www37.world4you.com
puppeteer.0  2022-08-18 17:39:02.783	debug	Write file to "wetterstation.png"
puppeteer.0  2022-08-18 17:39:00.289	debug	Message: {"command":"screenshot","message":{"url":"http://10.0.1.203:3000/d/sRh7W1m4k/wetterstation-copy-2?orgId=1&kiosk","clip":{"x":0,"y":0,"width":1000,"height":1100},"ioBrokerOptions":{"storagePath":"wetterstation.png"},"viewportOptions":{"width":1600,"height":1000}},"from":"system.adapter.javascript.0","callback":{"message":{"url":"http://10.0.1.203:3000/d/sRh7W1m4k/wetterstation-copy-2?orgId=1&kiosk","clip":{"x":0,"y":0,"width":1000,"height":1100},"ioBrokerOptions":{"storagePath":"wetterstation.png"},"viewportOptions":{"width":1600,"height":1000}},"id":298,"ack":false,"time":1660837140274},"_id":79533595}
puppeteer.0  2022-08-18 17:39:00.289	debug	Message: {"command":"screenshot","message":{"url":"http://10.0.1.203:3000/d/sRh7W1m4k/wetterstation-copy-2?orgId=1&kiosk","clip":{"x":0,"y":0,"width":1000,"height":1100},"ioBrokerOptions":{"storagePath":"wetterstation.png"},"viewportOptions":{"width":1600,"height":1000}},"from":"system.adapter.javascript.0","callback":{"message":{"url":"http://10.0.1.203:3000/d/sRh7W1m4k/wetterstation-copy-2?orgId=1&kiosk","clip":{"x":0,"y":0,"width":1000,"height":1100},"ioBrokerOptions":{"storagePath":"wetterstation.png"},"viewportOptions":{"width":1600,"height":1000}},"id":297,"ack":false,"time":1660837140273},"_id":79533594}

JS-Adapter: 6.0.0
Node.js: 16.15.1
NPM: 8.11.0
JS-Controller: 4.0.23

@Apollon77 Apollon77 changed the title Script lässt sich nicht stoppen Schedule in einem Skript kann nicht gestoppt werden bei Skript Stop Aug 18, 2022
@Apollon77 Apollon77 added the bug label Aug 18, 2022
@GermanBluefox
Copy link
Contributor

Can you show the script?

@Apollon77
Copy link
Contributor

ver ysimpel script just setting a schedule https://forum.iobroker.net/post/843652

@Negalein
Copy link
Author

Negalein commented Aug 21, 2022

Can you show the script?

schedule('*/3 * * * *', () => {
    log('schedule triggered', 'info');
    sendTo('puppeteer.0', 'screenshot', {
        url: 'http://10.0.1.203:3000/d/sRh7W1m4k/wetterstation-copy-2?orgId=1&kiosk',
        clip: {
            x: 0,
            y: 0,
            width: 1000,
            height: 1100
        },
        ioBrokerOptions: {
            storagePath: 'wetterstation.png'
        },
        viewportOptions: {
            width: 1600,
            height: 1000
        }
    }, obj => {
        if (obj.error) {
            log(`Error taking screenshot: ${obj.error}`, 'error');
            return;
        }
 
        log(`exec: wput -nc /opt/iobroker/iobroker-data/files/0_userdata.0/wetterstation.png ftp://xxxxx:xxxxx@www37.world4you.com`, 'info');
        exec('wput -nc /opt/iobroker/iobroker-data/files/0_userdata.0/wetterstation.png ftp://xxxxx:xxxxx@www37.world4you.com', (error, stdout, stderr) => {
            if (error) {
                log(`Error on upload: ${error} (${stderr})`, 'error');
            } else {
                log(`Upload finished: ${stdout}`, 'info');
            }
        });
    });
});

@MarkSau
Copy link

MarkSau commented Oct 4, 2022

Ich habe das auch in den Logs, wenn ich z.B. das script stoppe oder javascript neu starte

javascript.0 | 2022-10-04 17:08:10.601 | error | Error by canceling scheduled job "<Anonymous Job 32 2022-10-04T12:36:34.611Z>"
javascript.0 | 2022-10-04 17:08:10.600 | error | Error by canceling scheduled job "<Anonymous Job 31 2022-10-04T12:36:34.609Z>"
javascript.0 | 2022-10-04 17:08:10.600 | error | Error by canceling scheduled job "<Anonymous Job 30 2022-10-04T12:36:34.605Z>"

Mein Blockly Script dazu:

weckerscript.txt

@Steff42
Copy link

Steff42 commented Oct 14, 2022

Bei mir tritt der Fehler auch bei jedem Script in dem ein Schedule drin ist.

Bin auf
Admin 6.2.21
Script Engine 6.0.0
JS-Controller 4.0.23
Node.js: 16.16.0
NPM: 8.11.0

@Steff42
Copy link

Steff42 commented Oct 16, 2022

Ich weiß nicht ob das wichtig ist.

Der Fehler wird im Protokolle Tab anders angezeigt als im Log herunterladen Fenster. Hier mal ein Beispiel:
Der Fehler im Protokolle Tab, man beachte den Text zwischen den beiden ""
image

und hier Das gleiche unter Log herunterladen, es fehlt der Text Anonymous Job......

`
2022-10-16 11:45:58.139 - error: javascript.0 (2999613) Error by canceling scheduled job ""
2022-10-16 11:45:59.468 - info: admin.0 (3741803) <== Disconnect system.user.admin from ::ffff:192.168.0.1 javascript
2022-10-16 11:46:05.405 - info: admin.0 (3741803) ==> Connected system.user.admin from ::ffff:192.168.0.1
2022-10-16 11:47:00.041 - info: host.Smarthome instance system.adapter.uv-protect.0 started with pid 869394
2022-10-16 11:47:00.514 - info: uv-protect.0 (869394) starting. Version 0.3.6 in /opt/iobroker/node_modules/iobroker.uv-protect, node: v16.16.0, js-controller: 4.0.23
2022-10-16 11:47:07.046 - info: uv-protect.0 (869394) Terminated (NO_ERROR): Without reason
2022-10-16 11:47:07.580 - info: host.Smarthome instance system.adapter.uv-protect.0 terminated with code 0 (NO_ERROR)
2022-10-16 11:48:13.545 - info: javascript.0 (2999613) Stop script script.js.common.Telegram.Infos_um_0Uhr
2022-10-16 11:48:15.323 - info: javascript.0 (2999613) Start javascript script.js.common.Telegram.Infos_um_0Uhr
2022-10-16 11:48:15.342 - info: javascript.0 (2999613) script.js.common.Telegram.Infos_um_0Uhr: registered 1 subscription, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
2022-10-16 11:48:17.227 - info: admin.0 (3741803) <== Disconnect system.user.admin from ::ffff:192.168.0.1 javascript
2022-10-16 11:48:19.830 - info: admin.0 (3741803) ==> Connected system.user.admin from ::ffff:192.168.0.1
2022-10-16 11:48:23.717 - info: javascript.0 (2999613) Stop script script.js.common.Telegram.Infos_um_0Uhr
2022-10-16 11:48:23.718 - error: javascript.0 (2999613) Error by canceling scheduled job ""

`
Gruß Steffen

@Steff42
Copy link

Steff42 commented Oct 17, 2022

Habe mal etwas probiert.

Alle meine Schedule habe ich wie folgt programmiert:

schedule('* * * * *', function () { // jede Minute --> nur zum Testen
// do some crazy stuff
});

Stoppe ich ein Script mit solch einer Schedule-Schreibweise kommt der Fehler "Error by canceling scheduled job xxxx"

Programmiere ich aber das Schedule so:

let oSchedule = schedule('* * * * *', function () { // jede Minute --> nur zum Testen
// do some crazy stuff
});

und füge die folgenden Zeilen dazu

// bei Scriptstop
onStop (function scriptStop () {
clearSchedule(oSchedule);
}, 1000);

kommt beim Stoppen der Fehler nicht!?

@kopierschnitte
Copy link

Ich habe das Problem auch bei Blocklys. Selbst bei Skriptänderungen wegen Fehlern im Code sieht es so aus, als würde die alte Funktion innerhalb des Timers trotzdem noch ausgeführt.
Ein Neustart des JS-Adapters bringt dann obige Fehlermeldung (Error by canceling scheduled job...) und dann geht's wieder.

Apollon77 added a commit that referenced this issue Oct 25, 2022
…nute to prevent scripts from taking down ioBroker. Default are 1000 setState per minute. Only stops if the number is reached 2 minutes in a row! (fixes #1167)

* (Apollon77) Add createAlias method to create aliases for states (foxes #966)
* (Apollon77) Add setStateDelayed to selector (fixes #1131)
* (Apollon77) Add options to exec command (fixes #1152)
* (Apollon77) Fix issues with cancelling schedules when stopping scripts, fixes #1102
* update deps
Apollon77 added a commit that referenced this issue Oct 25, 2022
…nute to prevent scripts from taking down ioBroker. Default are 1000 setState per minute. Only stops if the number is reached 2 minutes in a row! (fixes #1167)

* (Apollon77) Add createAlias method to create aliases for states (foxes #966)
* (Apollon77) Add setStateDelayed to selector (fixes #1131)
* (Apollon77) Add options to exec command (fixes #1152)
* (Apollon77) Fix issues with cancelling schedules when stopping scripts, fixes #1102
* update deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants