Giter VIP home page Giter VIP logo

dev-server's Introduction

Logo

ioBroker (windows installer)

NPM version Downloads

NPM

Automate your life!

To install on Linux just run: npx @iobroker/install

To install on Windows: mkdir C:\iobroker && cd C:\iobroker && npx @iobroker/install or use installer

See ioBroker documentation for more information

ioBroker is an integration platform for the Internet of Things, focused on Building Automation, Smart Metering, Ambient Assisted Living, Process Automation, Visualization and Data Logging.

Concept

ioBroker is not just an application, it's more of a concept and a database schema. It offers a very easy way for systems to interoperate. ioBroker defines some common rules for a pair of databases used to exchange data and publish events between different systems.

architecture

Databases

ioBroker uses "in memory" database to hold the data and saves it on disk with reasonable intervals. There are two types of storage:

  • objects (meta/configuration information)
  • states (values)

Objects and states can be stored in "in memory" or in Redis.

Redis is an in-memory key-value data store and also a message broker with publish/subscribe pattern.

It's used to maintain and publish all states of connected systems.

Adapters

Systems are attached to ioBrokers databases via so-called adapters, technically processes running anywhere in the network and connecting all kinds of systems to ioBrokers databases. A connection to ioBrokers databases can be implemented in nearly any programming language on nearly any platform and an adapter can run on any host that is able to reach the databases via ip networking.

See actual list of adapters on iobroker.net

Security

ioBroker is designed to be accessed by trusted adapters inside trusted networks. This means that usually it is not a good idea to expose the ioBroker databases, adapters or any smart home devices directly to the internet or, in general, to an environment where untrusted clients can directly access these network services. Adapters that offer services supposed to be exposed to the internet should be handled with care. You should always activate HTTPS and use valid certificates for web, admin if open it for internet or for example use it with additional security measures like VPN, VLAN and reverse proxies.

Getting Started

Operating System and Hardware

ioBroker.js-controller should run on any hardware and OS that runs Node.js (ARM, x86, Windows, Linux, OSX).

ioBroker spawns a new Node.js process for every adapter instance, so RAM becomes a limiting factor. A single adapter's memory fingerprint is roundabout 10 to 60 MB.

Installation and first steps

Community support

Logos and pictures

All logos are protected by copyright and may not be used without permission.

Please request permission via [email protected]

Logos

License

This module is distributor under the MIT License (MIT). Please notice, that other ioBroker adapters can have different licenses.

The MIT License (MIT)

Copyright (c) 2014-2024 bluefox [email protected], Copyright (c) 2014 hobbyquaker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

dev-server's People

Contributors

alcalzone avatar apollon77 avatar dependabot[bot] avatar foxriver76 avatar garfonso avatar germanbluefox avatar mcm1957 avatar seqway avatar stevenengland avatar unclesamswiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dev-server's Issues

skip new admin 5 intro tab

Not sure if possible... but if somehow possible, we should try to skip that for devserver (might be as easy as set some object?).

Mehrfache Ausführung

Hallo,

gleich vorweg, der Fehler kann auch bei mir liegen! Ich bin kein prof. Programmierer!

Ich habe jetzt mal versucht mit dem dev-server meinen Adapter weiter zu entwickeln, klappt soweit sehr gut! Dabei ist mir jedoch ein eigenwilliges Verhalten aufgefallen. Wenn ich am Code (main.js) gearbeitet habe, kam es häufig danach bei Zeit Funktionen (Interval & Timeout) zu einem merkwürdigen Verhalten. Der Code wurde Teils doppelt ausgeführt, so als ob zwei Instanzen gleichzeitig laufen.

Erst nach einem upload lief der Adapter dann augenscheinlich korrekt.

dev-server startet nicht mehr.

Ich habe ein Problem mit dem dev-server. ich bekomme ihn nicht gestartet.

Im Terminalfenster wird mir dieser Fehler angezeigt nach ausführen von dev-server run

Error: Couldn't start js-controller
    at DevServer.waitForJsController (C:\Users\aruttkamp\AppData\Roaming\npm\node_modules\@iobroker\dev-server\dist\index.js:444:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DevServer.startJsController (C:\Users\aruttkamp\AppData\Roaming\npm\node_modules\@iobroker\dev-server\dist\index.js:454:9)
    at async DevServer.run (C:\Users\aruttkamp\AppData\Roaming\npm\node_modules\@iobroker\dev-server\dist\index.js:296:9)
    at async Object.handler (C:\Users\aruttkamp\AppData\Roaming\npm\node_modules\@iobroker\dev-server\dist\index.js:100:162)

Inhalt der Log-datei :

[iobroker.2023-08-15.log](https://github.com/ioBroker/dev-server/files/12352248/iobroker.2023-08-15.log)

admin 6.8.0 node: v18.17.1, js-controller: 5.0.11 Windows 11

dev-server setup --force , sowie löschen von .dev-server und erneutes setup habe ich ausgeführt.

Lief alles bis ich den jsController updaten wollte und dev-server update ausgeführt habe.

Support choosing a local js-controller

When developing the js-controller we would also need the option to use a local js-contzroller as basis.

Ideally also the controller is built (or linked?), watched and restarted when files in this scope change

Run `npm build` before starting watch

If there is a build script defined, it should be run before watch, otherwise the initial adapter setup will contain the old version of the adapter and only the first code change will actually trigger an update

[Improvement / Doku] Anleitung für Einsatz von dev-server mit VS-Code (mittels direktem Link)

@ english only readers:
I write the following issue in german as it already exists as a german Telegram discussion. If someone needs an english translation, please contact me @mcm1957, I'll do my best.


In Abstimmung mit @UncleSamSwiss lege ich hier (m)eine Anleitung für die Anwendung des dev-servers für das Debuggen reiner Script Adapter unter VS-Code ab und rege an, diesen Ablauf ggF in den dev-server oder eine Aleitung zu übernehmen falls sich bei vertiefter Beurteilung keine Nachteile feststellen lassen.

Vorteil der Link Methode:
JS Script liegt nur genau an einer Stelle und vsCode liest und schreibt genau das eine File

Nachteil:
Adapter muss in VS manuell restartet werden; watch wird nicht verwendet.

Was habe ich gemacht:

A) dev-server installiert und mittels dev-server setup normal initialisisert.

B) Im Verzeichnis .dev-server\default\node_modules den Adapter Tree gelöscht

cd .dev-server\default\node_modules
rmdir /s /q ioBroker.<ADAPTERNAME>

C) einen Symlink DIREKT von node_modules in mein GIT Verzeichnis eingerichtet

mklink /d ioBroker.<ADAPTERNAME> ..\..\..

D) den NODE_PATH gesetzt

SETX NODE_PATH .dev-server\default\node_modules

Kontrolle mittel SET Befehls. Der Output sollte enthalten
Auszug aus Eingabeaufforderung, Befehl SET

NODE_PATH=.dev-server/default/node_modules

E) setup vsCode Umgebung; dazu folgenden Eintrag in lauch.json Config ergänzen dabei den Namen des Adapterscripts ggf. anpassen falls dieser nicht main.js lautet.

    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Program",
            "program": "${workspaceFolder}/main.js",
            "args": ["--instance", "0", "--force", "--log"],
            "request": "launch",
            "stopOnEntry": true,
            "console": "internalConsole",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "pwa-node"
        }
  ]

F) Zum Debuggen setzte mich nun in das GIT Adapter Verzeichnis und starte dort den dev-server NUR mit run

dev-server run

Direkt in vsCode starte ich dann den Adaptercode und kann debuggen, den Adapter restarten etc. Scheint bisher alles zu gehen - ausgenommen die run/stop Anzeige im Admin. Aber das ist bei extern gestarten Prozessen ja wohl normal.

adapter fails to run when running dev-server watch for newly created adapter

I did just create an adapter (TS + react) with adapter creator. I did specify to use dev-server in the process. So dev-server was already setup by adapter creator.
Now, after a problem with dependencies, the build works and I did want to start the adapter with dev-server watch to have a look at the config and so on, but the adapter does not start. It fails with "invalid configuration".

I had a look at the objects database and there is no instance configured for the adapter at all. This is probably why it fails.
I had to manually add the instance and disable it and now it seems to be working.

It would be nice if we can make this progress a bit smoother, especially for new adapers / devs.

D:\iobroker\ioBroker.ico>dev-server watch
Using profile default
Using profile name "default"
Using adapter name "ico"
Install local iobroker.ico
D:\iobroker\ioBroker.ico> npm run build

> [email protected] prebuild D:\iobroker\ioBroker.ico
> rimraf ./build


> [email protected] build D:\iobroker\ioBroker.ico
> npm run build:ts && npm run build:parcel


> [email protected] build:ts D:\iobroker\ioBroker.ico
> tsc -p tsconfig.build.json


> [email protected] build:parcel D:\iobroker\ioBroker.ico
> parcel build admin/src/index.tsx -d admin/build

√  Built in 872ms.

admin\build\index.js.map     ‼  2.18 MB    137ms
admin\build\index.js          825.85 KB    613ms
admin\build\index.css.map       7.32 KB      3ms
admin\build\index.css           3.39 KB    124ms
D:\iobroker\ioBroker.ico> npm pack
Packed to iobroker.ico-0.0.1.tgz
D:\iobroker\ioBroker.ico\.dev-server\default> npm install "D:\iobroker\ioBroker.ico\iobroker.ico-0.0.1.tgz"

> [email protected] install D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\diskusage
> node-gyp rebuild


D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\diskusage>if not defined npm_config_node_gyp (node "C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-
gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:315:5)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1048:16)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\achim\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\diskusage
gyp ERR! node -v v14.16.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

> [email protected] install D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\unix-dgram
> node-gyp rebuild


D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\unix-dgram>if not defined npm_config_node_gyp (node "C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node
-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\achim\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:315:5)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1048:16)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\achim\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\unix-dgram
gyp ERR! node -v v14.16.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\diskusage):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\unix-dgram):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ [email protected]
added 1 package from 1 contributor and audited 376 packages in 3.512s

11 packages are looking for funding
  run `npm fund` for details

found 1 high severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
D:\iobroker\ioBroker.ico\.dev-server\default> node node_modules/iobroker.js-controller/controller.js
Running inside D:\iobroker\ioBroker.ico\.dev-server\default
Starting React build
Waiting for first successful React build...
D:\iobroker\ioBroker.ico> npm run watch:parcel
2021-07-10 08:55:49.625  - info: host.dev-ico-KM iobroker.js-controller version 3.3.14 js-controller starting
2021-07-10 08:55:49.626  - info: host.dev-ico-KM Copyright (c) 2014-2021 bluefox, 2014 hobbyquaker
2021-07-10 08:55:49.627  - info: host.dev-ico-KM hostname: dev-ico-KM, node: v14.16.0
2021-07-10 08:55:49.627  - info: host.dev-ico-KM ip addresses: fe80::2430:7f32:8da:b40f 192.168.0.3
2021-07-10 08:55:49.632  - debug: host.dev-ico-KM-Server Data File: D:\iobroker\ioBroker.ico\.dev-server\default\iobroker-data\objects.json
2021-07-10 08:55:49.638  - debug: host.dev-ico-KM-Server  Redis inMem-objects listening on port 9001
2021-07-10 08:55:49.639  - debug: host.dev-ico-KM Redis Objects: Use Redis connection: 127.0.0.1:26430
2021-07-10 08:55:49.645  - debug: host.dev-ico-KM Objects client ready ... initialize now
2021-07-10 08:55:49.646  - debug: host.dev-ico-KM Objects create System PubSub Client
2021-07-10 08:55:49.646  - debug: host.dev-ico-KM Objects client initialize lua scripts
2021-07-10 08:55:49.652  - debug: host.dev-ico-KM Objects connected to redis: 127.0.0.1:26430
2021-07-10 08:55:49.654  - debug: host.dev-ico-KM-Server Data File: D:\iobroker\ioBroker.ico\.dev-server\default\iobroker-data\states.json
2021-07-10 08:55:49.656  - debug: host.dev-ico-KM-Server  Redis inMem-states listening on port 9000
2021-07-10 08:55:49.656  - debug: host.dev-ico-KM Redis States: Use Redis connection: 127.0.0.1:24430
2021-07-10 08:55:49.658  - debug: host.dev-ico-KM States create System PubSub Client
2021-07-10 08:55:49.660  - debug: host.dev-ico-KM States connected to redis: 127.0.0.1:24430
2021-07-10 08:55:49.668  - info: host.dev-ico-KM connected to Objects and States
2021-07-10 08:55:49.669  - debug: host.dev-ico-KM Could not read notifications.json: D:\iobroker\ioBroker.ico\.dev-server\default\iobroker-data\notifications.json: ENOENT: no such file or directory, open 'D:\iobroker\ioBroker.i
co\.dev-server\default\iobroker-data\notifications.json'
2021-07-10 08:55:49.679  - info: host.dev-ico-KM added notifications configuration of host
2021-07-10 08:55:49.684  - debug: host.dev-ico-KM Plugin sentry Initialize Plugin (enabled=true)

> [email protected] watch:parcel D:\iobroker\ioBroker.ico
> parcel admin/src/index.tsx -d admin/build
2021-07-10 08:55:49.813  - info: host.dev-ico-KM 1 instance found
2021-07-10 08:55:49.813  - debug: host.dev-ico-KM check instance "system.adapter.admin.0" for host "dev-ico-KM"
host.dev-ico-KM check instance "system.adapter.admin.0" for host "dev-ico-KM"
2021-07-10 08:55:49.815  - info: host.dev-ico-KM starting 1 instance
2021-07-10 08:55:49.823  - debug: host.dev-ico-KM added notifications configuration of system.adapter.admin.0
2021-07-10 08:55:49.824  - debug: host.dev-ico-KM startInstance admin.0 loglevel=info, compact=false
2021-07-10 08:55:49.828  - info: host.dev-ico-KM instance system.adapter.admin.0 started with pid 29460
Server running at http://localhost:1234
√  Built in 6.38s.
Starting browser-sync
[HPM] Proxy created: /adapter/ico/**,/browser-sync/**  -> http://localhost:22430
[HPM] Proxy rewrite rule created: "^/adapter/ico/" ~> "/"
[HPM] Proxy created: !/adapter/ico/**,!/browser-sync/**  -> http://localhost:20430
Starting web server on port 8085
╭─────────────────────────────────────────────────────────╮
│                                                         │
│   Admin is now reachable under http://localhost:8085/   │
│                                                         │
╰─────────────────────────────────────────────────────────╯
Starting tsc --watch
Waiting for first successful tsc build...
D:\iobroker\ioBroker.ico> npm run watch:ts
WebSocket open

> [email protected] watch:ts D:\iobroker\ioBroker.ico
> tsc -p tsconfig.build.json --watch
08:55:57 - Starting compilation in watch mode...
[HPM] Upgrading to WebSocket
================================== > LOG REDIRECT system.adapter.admin.0 => true [system.adapter.admin.0.logging]
2021-07-10 08:55:57.610  - debug: host.dev-ico-KM Incoming Host message getRepository
2021-07-10 08:55:57.612  - info: host.dev-ico-KM Updating repository "stable" under "http://download.iobroker.net/sources-dist.json"
hash changed or no sources cached => force download of new sources
2021-07-10 08:55:58.724  - debug: host.dev-ico-KM Incoming Host message getInstalled
2021-07-10 08:55:59.131  - debug: host.dev-ico-KM Incoming Host message getNotifications

08:55:59 - Found 0 errors. Watching for file changes.
Starting file system sync from D:\iobroker\ioBroker.ico
2021-07-10 08:55:59.234  - debug: host.dev-ico-KM Incoming Host message getHostInfo
Synchronizing build\main.js
Synchronizing build\main.js.map
Patched D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\iobroker.ico\build\main.js.map from D:\iobroker\ioBroker.ico\build\main.js.map
Synchronizing build\lib\tools.js
Synchronizing build\lib\tools.js.map
Starting nodemon for D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\iobroker.ico\build\main.js
Patched D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\iobroker.ico\build\lib\tools.js.map from D:\iobroker\ioBroker.ico\build\lib\tools.js.map
[nodemon] 2.0.11
[nodemon] to restart at any time, enter `rs`
[nodemon] ignoring: .\.dev-server\default\node_modules\iobroker.ico\admin/**/*
[nodemon] watching path(s): .dev-server\default\node_modules\iobroker.ico\**\*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node --inspect D:\iobroker\ioBroker.ico\.dev-server\default\node_modules\iobroker.ico\build\main.js --debug 0`
[nodemon] spawning
[nodemon] child pid: 34956
[nodemon] watching 8 files
Debugger listening on ws://127.0.0.1:9229/b8506643-65a4-4910-801e-6500fd6d5f83
For help, see: https://nodejs.org/en/docs/inspector
╭───────────────────────────────────────────────────╮
│                                                   │
│   Debugger is now available on process id 35520   │
│                                                   │
╰───────────────────────────────────────────────────╯
2021-07-10 08:55:59.734  - debug: ico.0 (35520) Redis Objects: Use Redis connection: 127.0.0.1:26430
2021-07-10 08:55:59.744  - debug: ico.0 (35520) Objects client ready ... initialize now
2021-07-10 08:55:59.747  - debug: ico.0 (35520) Objects create System PubSub Client
2021-07-10 08:55:59.748  - debug: ico.0 (35520) Objects create User PubSub Client
2021-07-10 08:55:59.750  - debug: ico.0 (35520) Objects client initialize lua scripts
2021-07-10 08:55:59.758  - debug: ico.0 (35520) Objects connected to redis: 127.0.0.1:26430
2021-07-10 08:55:59.765  - debug: ico.0 (35520) objectDB connected
2021-07-10 08:55:59.767  - debug: ico.0 (35520) Redis States: Use Redis connection: 127.0.0.1:24430
2021-07-10 08:55:59.771  - debug: ico.0 (35520) States create System PubSub Client
2021-07-10 08:55:59.771  - debug: ico.0 (35520) States create User PubSub Client
2021-07-10 08:55:59.775  - debug: ico.0 (35520) States connected to redis: 127.0.0.1:24430
2021-07-10 08:55:59.776  - debug: ico.0 (35520) statesDB connected
2021-07-10 08:55:59.779  - error: ico.0 (35520) ico.0 invalid config
2021-07-10 08:55:59.779  - warn: ico.0 (35520) Terminated (INVALID_ADAPTER_CONFIG): Without reason
2021-07-10 08:56:00.015  - debug: host.dev-ico-KM Incoming Host message getLogs
[nodemon] app crashed - waiting for file changes before starting...

VSCode (Win10): Debugging/Breakpoints nur unterhalb .dev-server/

Siehe Forum-Beitrag von OliverIO: https://forum.iobroker.net/post/826766
Bei mir verhält sich das auch so, daher öffne ich jetzt mal dieses Issue.

Issue

VS Code erkennt die Breakpoints nur in <Adapter-Verzeichnis>\.dev-server\default\node_modules\iobroker.<Adapter-Name>\main.js und nicht in <Adapter-Verzeichnis>\main.js

Aufgrund "stopOnEntry": true in der launch.json hält bei "F5" das Debugging hier:
image

main.js-Pfad: C:\iobroker\DEV1\node_modules\ioBroker.mytest03-js\.dev-server\default\node_modules\iobroker.mytest03-js\main.js

Breakpoints werden ebenso erkannt:
image

Die C:\iobroker\DEV1\node_modules\ioBroker.mytest03-js\main.js wird aber ignoriert und Breakpoint wie hier auf Zeile 39 gesetzt nicht erkannt.
image

Diagnose Breakpoint Problems in VS Code, also Ctrl+Shift+P > "Debug: Diagnose Breakpoint Problems", zeigt:
image

Diagnose Breakpoint Problems, "What scripts and sourcemaps are loaded" listet außerdem ausschließlich Dateien unterhalb von C:\iobroker\DEV1\node_modules\ioBroker.mytest03-js\.dev-server\default\

Verwendetes System und Setup

System:

  • Entwicklungsrechner: Windows 10 (alles lokal, nichts remote)
  • Standard-ioBroker wurde installiert unter c:\ioBroker\DEV1\
  • Visual Studio Code wird verwendet.

Vorgehensweise:

  1. Standard-ioBroker zur Sicherheit gestoppt: Öffnen der ioBroker-Konsole (z.B. mit [WIN+s > iob > Enter]).
    In der Konsole: iob stop ausführen, und nach Ausführung Konsole schließen.
  2. Neue Windows-Konsole z.B. mit [WIN+s > cmd > Enter] öffnen und cd C:\iobroker\DEV1\node_modules ausführen.
  3. npx @iobroker/create-adapter ausführen, "typische" Einstellungen, Sprache: JavaScript, Name: mytest03-js (d.h. Adapter-Pfad = C:\iobroker\DEV1\node_modules\ioBroker.mytest03-js). Option "dev-server" aktiviert.
  4. VS Code öffnen, Menü: "Datei/Ordner öffnen...", Verzeichnis C:\iobroker\DEV1\node_modules\ioBroker.mytest03-js wählen.
  5. Terminal öffnen (sollte jetzt im o.g. Pfad sein, falls nicht: cd C:\iobroker\DEV1\node_modules\ioBroker.mytest03-js ausführen).
  6. In Terminal dev-server watch --noStart ausführen.
  7. Debugger öffnen (CTRL+SHIFT+d), Oben neben "Ausführen und Debuggen" auf Zahnrad, "node" wählen, und in der nun neu erzeugten launch.json den bestehenden Code mit Folgendem überschreiben:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "request": "launch",
            "type": "node",
            "args": ["--debug", "0"],
            "stopOnEntry": true, // - break immediately when the program launches
            "program": "node_modules/iobroker.mytest03-js/main.js", // executable or file to run when launching the debugger
            "cwd": "${workspaceFolder}/.dev-server/default", // current working directory for finding dependencies and other files
            "skipFiles": ["<node_internals>/**"],
            "outputCapture": "std", // https://github.com/ioBroker/dev-docs/issues/35
        },     
    ]
}
  1. In Debugger oben unter "Ausführen und debuggen" den neuen Eintrag "Launch" auswählen.
  2. Debugging mit F5 starten

Dev server cannot be started with React admin page

The server throws this error, I hope you can do something with it.

> [email protected] watch:parcel C:\Users\Dennis\Documents\GitHub\ioBroker.matomo
> parcel admin/src/index.tsx -d admin/build --hmr-port 1235
Server running at http://localhost:1234
×  C:\Users\Dennis\Documents\GitHub\ioBroker.matomo\node_modules\@iobroker\adapter-react\GenericApp.js:12:45: Cannot resolve dependency '@sentry/browser'
  10 | var _Connection = _interopRequireWildcard(require("./Connection"));
  11 |
> 12 | var Sentry = _interopRequireWildcard(require("@sentry/browser"));
     |                                             ^
  13 |
  14 | var _propTypes = _interopRequireDefault(require("prop-types"));
  15 |

changing of io-package.json does not trigger upload (dev-server watch mode)

The dev-server running in watch mode seems to be missing changes to io-package.json.

I've added common.messagebox to the dev-server wondering why this did not work. I had to perform a manual dev-server upload to make it working.

Please check whether watching io-package.json and triggering an automatic upoad could be implemented without much effort and without considerable runtime load (as changing io-package will be ruther seldom)

Handle CTRL-C more gracefull ...

It seems to me that a CTRL-C is not handled gracefully ... the started controller seems not to always do a clean shutdown sometimes ... and then he thinks on next starte that adapters still run and so we have multiple restarts ...

Include .DS_Store file in the standard .gitignore

Hello,
as a Mac user i am facing the problem that MacOS (Finder) creates everywhere the .DS_Store file which causes some strange behaviour e.g. in VS Code because the files are always been shown as modified.
So i need to manually do it in the .gitignore

maybe it is a good idea to implement it in the standard so that especially for Mac Users it is not forgotten to exclude this file !

fill devserver with predefined set of objects and data

Devserver is great for testing adapters that "fill" iobroker, i.e. create devices based on hardware devices or pull data from some external source.

But for testing / developing adapters that show what is already inside iobroker (for example an UI adapter) it can be tedious to (re-)create all the objects and states in ioBroker using the admin interface. For this kind of adapters (especially with automatic device creation moving forward) it would be nice to create a predefined set of objects (and states?) on setup and maybe have a way to reset this predefined state (i.e. delete all objects and import the predefined ones - or is delete too much?).

The object definition could be as simple as a JSON file (admin exports objects as { id: ioBrokerObject } JSON).

Add option to specify local library dirs that are also updated/watched

I'm as a ioBroker adapter developer that also uses self developed libraries (and not have all logic "in the adapter") and use these libraries as dependencies in the adapter would like to have an option to also specify additional directories of these "deps" that are watched and also updated when the dev-server updates anything.

Right now I need stop the dev-server, execute some "cp" commands and then start dev-server again for each change I do on such a library

dev-server no longer connects when using Node 18

I tried the new Node 18 version and found out that the dev-server doesn't connect at all anymore, there is always only this:

[HPM] Error occurred while proxying request localhost:8081/ to http://localhost:20426/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while proxying request localhost:8081/favicon.ico to http://localhost:20426/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

As soon as I switch back to node 16 (LTS), it connects again as before.
There are no other error messages only what I posted above.

COMMAND undefined, COMM instead

const child = processes.find((p) => p.COMMAND.match(/node/i));

TypeError: Cannot read property 'match' of undefined at /usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:398:59 at Array.find (<anonymous>) at DevServer.waitForNodeChildProcess (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:398:37) at processTicksAndRejections (node:internal/process/task_queues:93:5) at async DevServer.startAdapterDebug (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:391:27) at async DevServer.debug (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:170:9) at async Object.handler (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:86:28)

On my MacOS with nodejs v15.5.1, the object looks like this:

[ { PPID: '65302', PID: '65304', STAT: 'S+', COMM: '/usr/local/Cellar/node/15.5.1/bin/node' } ]

Firefox fails to connect after a few changes

If you run dev-server watch and change something on the UI it will update in Browser automagically. In Firefox this already leads to errors in Console:
dev-server-errors-update

Usually after the third change a reconnect does never happen. The frontend seems to be stuck in some kind of retry loop and never can create a new connection. See image and text log below.

In the end there is a text log from dev-server console (which is not very talkactive).

If the Browser is in this state you need to either close and restart the browser or dev-server.

dev-server-reconnect


██╗ ██████╗ ██████╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗ 
██║██╔═══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝██╔══██╗
██║██║   ██║██████╔╝██████╔╝██║   ██║█████╔╝ █████╗  ██████╔╝
██║██║   ██║██╔══██╗██╔══██╗██║   ██║██╔═██╗ ██╔══╝  ██╔══██╗
██║╚██████╔╝██████╔╝██║  ██║╚██████╔╝██║  ██╗███████╗██║  ██║
╚═╝ ╚═════╝ ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
index.js:66689:11
Nice to see you here! :) Join our dev community here https://github.com/ioBroker/ioBroker or here https://github.com/iobroker-community-adapters index.js:66690:11
Help us to create open source project with reactJS! index.js:66691:11
See you :) index.js:66692:11
[2021-07-20T08:55:50.134Z] Try to connect socket.io.js:59:41
1 index.js:80139:13
Source map error: Error: request failed with status 404
Resource URL: http://localhost:8085/adapter/ico/build/index.js
Source Map URL: /index.js.map
2
[2021-07-20T08:56:07.266Z] ws connection error: CLOSE_GOING_AWAY socket.io.js:61:32
1 index.js:80139:13
[2021-07-20T08:56:07.274Z] Start reconnect 0 socket.io.js:59:41
[2021-07-20T08:56:07.276Z] Try to connect socket.io.js:59:41
Uncaught SyntaxError: missing } after property list
index.js:3430:113note: { opened at line 120, column 3index.js:120:3
Material-UI: the createMuiTheme function was renamed to createTheme.

You should use `import { createTheme } from '@material-ui/core/styles'` index.js:32757:15

██╗ ██████╗ ██████╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗ 
██║██╔═══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝██╔══██╗
██║██║   ██║██████╔╝██████╔╝██║   ██║█████╔╝ █████╗  ██████╔╝
██║██║   ██║██╔══██╗██╔══██╗██║   ██║██╔═██╗ ██╔══╝  ██╔══██╗
██║╚██████╔╝██████╔╝██║  ██║╚██████╔╝██║  ██╗███████╗██║  ██║
╚═╝ ╚═════╝ ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
index.js:66689:11
Nice to see you here! :) Join our dev community here https://github.com/ioBroker/ioBroker or here https://github.com/iobroker-community-adapters index.js:66690:11
Help us to create open source project with reactJS! index.js:66691:11
See you :) index.js:66692:11
[2021-07-20T08:56:08.307Z] Try to connect socket.io.js:59:41
Source map error: Error: request failed with status 404
Resource URL: http://localhost:8085/adapter/ico/build/index.js
Source Map URL: /index.js.map

2 index.js:80139:13
[2021-07-20T08:56:22.416Z] ws connection error: CLOSE_GOING_AWAY socket.io.js:61:32
2 index.js:80139:13
XHRPOSThttp://localhost:8085/browser-sync/socket.io/?EIO=3&transport=polling&t=Nh38M29&sid=7O1UnS9WkElinWaqAAAC
[HTTP/1.1 400 Bad Request 2ms]

[2021-07-20T08:56:22.423Z] Start reconnect 0 socket.io.js:59:41
[2021-07-20T08:56:22.425Z] Try to connect socket.io.js:59:41
Uncaught SyntaxError: missing } after property list
index.js:62757:1422note: { opened at line 120, column 3index.js:120:3
Material-UI: the createMuiTheme function was renamed to createTheme.

You should use `import { createTheme } from '@material-ui/core/styles'` index.js:32757:15

██╗ ██████╗ ██████╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗ 
██║██╔═══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝██╔══██╗
██║██║   ██║██████╔╝██████╔╝██║   ██║█████╔╝ █████╗  ██████╔╝
██║██║   ██║██╔══██╗██╔══██╗██║   ██║██╔═██╗ ██╔══╝  ██╔══██╗
██║╚██████╔╝██████╔╝██║  ██║╚██████╔╝██║  ██╗███████╗██║  ██║
╚═╝ ╚═════╝ ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
index.js:66689:11
Nice to see you here! :) Join our dev community here https://github.com/ioBroker/ioBroker or here https://github.com/iobroker-community-adapters index.js:66690:11
Help us to create open source project with reactJS! index.js:66691:11
See you :) index.js:66692:11
[2021-07-20T08:56:23.555Z] Try to connect socket.io.js:59:41
Source map error: Error: request failed with status 404
Resource URL: http://localhost:8085/adapter/ico/build/index.js
Source Map URL: /index.js.map

[2021-07-20T08:56:26.560Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:56:26.561Z] Start reconnect 0 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771383555&name=ico. socket.io.js:91:21
[2021-07-20T08:56:26.561Z] Try to connect socket.io.js:59:41
The connection to ws://localhost:8085/?sid=1626771383555&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:56:26.564Z] Start reconnect 1 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771386562&name=ico. socket.io.js:91:21
[2021-07-20T08:56:26.564Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:56:26.565Z] Reconnect is already running 1 socket.io.js:59:41
The connection to ws://localhost:8085/?sid=1626771386562&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:56:26.565Z] Reconnect is already running 1 socket.io.js:59:41
[2021-07-20T08:56:26.565Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:56:26.565Z] Reconnect is already running 1 socket.io.js:59:41
[2021-07-20T08:56:27.573Z] Try to connect socket.io.js:59:41
XHRPOSThttp://localhost:8085/browser-sync/socket.io/?EIO=3&transport=polling&t=Nh38NXG&sid=g39Rn7-QKhejtShHAAAE
[HTTP/1.1 400 Bad Request 5322ms]

[2021-07-20T08:56:30.588Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:56:30.589Z] Start reconnect 2 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771387573&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771387573&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:56:30.590Z] Reconnect is already running 2 socket.io.js:59:41
[2021-07-20T08:56:30.590Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:56:30.591Z] Reconnect is already running 2 socket.io.js:59:41
[2021-07-20T08:56:32.603Z] Try to connect socket.io.js:59:41
XHRPOSThttp://localhost:8085/browser-sync/socket.io/?EIO=3&transport=polling&t=Nh38OlV&sid=g39Rn7-QKhejtShHAAAE
[HTTP/1.1 400 Bad Request 317ms]

Firefox can’t establish a connection to the server at ws://localhost:8085/browser-sync/socket.io/?EIO=3&transport=websocket&sid=g39Rn7-QKhejtShHAAAE. browser-sync-client.js:10:60395
The connection to ws://localhost:8085/browser-sync/socket.io/?EIO=3&transport=websocket&sid=g39Rn7-QKhejtShHAAAE was interrupted while the page was loading. browser-sync-client.js:10:60395
3 index.js:80139:13
Firefox can’t establish a connection to the server at ws://localhost:8085/browser-sync/socket.io/?EIO=3&transport=websocket&sid=cSDrqlt9TCjCrAS3AAAF. browser-sync-client.js:10:60395
The connection to ws://localhost:8085/browser-sync/socket.io/?EIO=3&transport=websocket&sid=cSDrqlt9TCjCrAS3AAAF was interrupted while the page was loading. browser-sync-client.js:10:60395
[2021-07-20T08:56:49.704Z] ws connection error: CLOSE_GOING_AWAY socket.io.js:61:32
3 index.js:80139:13
[2021-07-20T08:56:49.711Z] Start reconnect 0 socket.io.js:59:41
[2021-07-20T08:56:49.711Z] Try to connect socket.io.js:59:41
[2021-07-20T08:56:52.728Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:56:52.729Z] Start reconnect 1 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771409712&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771409712&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:56:52.729Z] Reconnect is already running 1 socket.io.js:59:41
[2021-07-20T08:56:52.730Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:56:52.730Z] Reconnect is already running 1 socket.io.js:59:41
[2021-07-20T08:56:53.741Z] Try to connect socket.io.js:59:41
[2021-07-20T08:56:56.755Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:56:56.756Z] Start reconnect 2 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771413741&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771413741&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:56:56.757Z] Reconnect is already running 2 socket.io.js:59:41
[2021-07-20T08:56:56.757Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:56:56.758Z] Reconnect is already running 2 socket.io.js:59:41
[2021-07-20T08:56:58.765Z] Try to connect socket.io.js:59:41
[2021-07-20T08:57:01.780Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:57:01.782Z] Start reconnect 3 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771418765&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771418765&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:57:01.782Z] Reconnect is already running 3 socket.io.js:59:41
[2021-07-20T08:57:01.782Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:57:01.782Z] Reconnect is already running 3 socket.io.js:59:41
[2021-07-20T08:57:04.794Z] Try to connect socket.io.js:59:41
[2021-07-20T08:57:07.798Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:57:07.798Z] Start reconnect 4 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771424794&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771424794&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:57:07.799Z] Reconnect is already running 4 socket.io.js:59:41
[2021-07-20T08:57:07.799Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:57:07.800Z] Reconnect is already running 4 socket.io.js:59:41
[2021-07-20T08:57:11.809Z] Try to connect socket.io.js:59:41
[2021-07-20T08:57:14.817Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:57:14.817Z] Start reconnect 5 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771431809&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771431809&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:57:14.818Z] Reconnect is already running 5 socket.io.js:59:41
[2021-07-20T08:57:14.819Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:57:14.819Z] Reconnect is already running 5 socket.io.js:59:41
[2021-07-20T08:57:19.824Z] Try to connect socket.io.js:59:41
[2021-07-20T08:57:22.829Z] No READY flag received in 3 seconds. Re-init socket.io.js:60:32
[2021-07-20T08:57:22.830Z] Start reconnect 5 socket.io.js:59:41
Firefox can’t establish a connection to the server at ws://localhost:8085/?sid=1626771439824&name=ico. socket.io.js:91:21
The connection to ws://localhost:8085/?sid=1626771439824&name=ico was interrupted while the page was loading. socket.io.js:91:21
[2021-07-20T08:57:22.831Z] Reconnect is already running 5 socket.io.js:59:41
[2021-07-20T08:57:22.831Z] ws connection error: CLOSE_ABNORMAL socket.io.js:61:32
[2021-07-20T08:57:22.831Z] Reconnect is already running 5 socket.io.js:59:41

(look for index.js:80139:13 to see output of 1, 2 and 3. That is where the updates were processed).

2021-07-20 10:44:30.180  - debug: host.dev-ico-KM Incoming Host message getLogs
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
√  Built in 1.04s.
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
√  Built in 1.14s.
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
√  Built in 657ms.
2021-07-20 10:49:18.054  - debug: host.dev-ico-KM Incoming Host message getInstalled
2021-07-20 10:49:18.076  - debug: host.dev-ico-KM Incoming Host message getRepository
Send diag info: {"uuid":"028e5730-dd03-bfd3-661f-67eae064f8eb","language":"de","country":"","hosts":[{"version":"3.3.14","platform":"Javascript/Node.js","type":"win32"}],"node":"v14.16.0","arch":"x64","adapters":{"admin":{"vers
ion":"5.1.10","platform":"Javascript/Node.js"},"ico":{"version":"0.0.1","platform":"Javascript/Node.js"}},"statesType":"file","objectsType":"file","model":"AMD Ryzen 9 5950X 16-Core Processor            ","cpus":32,"mem":686363
72992,"ostype":"Windows_NT","city":""}
2021-07-20 10:49:20.349  - debug: host.dev-ico-KM Incoming Host message readBaseSettings
[HPM] Client disconnected

[cosmetic] Couldn't check .gitignore: Error: Command failed: git status --short --untracked-files=all

Minor cosmetic eroor::

When using adpgter cretor and 'create git repo' is deselected the following error occures:

Verifying .npmignore and .gitignore
E:\GitHub\mcm1957\ioBroker.test230706> npm pack --dry-run
E:\GitHub\mcm1957\ioBroker.test230706> git status --short --untracked-files=all
Couldn't check .gitignore: Error: Command failed: git status --short --untracked-files=all
fatal: not a git repository (or any of the parent directories): .git

Either this check needs to be skipped or better handled if no git environment is (yet) set up.

Extract from DOS Box:

[create-adapter.json.zip](https://github.com/ioBroker/dev-server/files/11967850/create-adapter.json.zip)

That's it. Please wait a minute while I get this working...
[1/3] Generating files...
Using Legacy Google Translate
[2/3] Installing dependencies...

added 359 packages in 6m
[3/3] Installing dev-server...

changed 406 packages in 1m
Using default profile default
Using profile name "default"
Using adapter name "test230706"
Setting up in E:\GitHub\mcm1957\ioBroker.test230706\.dev-server\default
Verifying .npmignore and .gitignore
E:\GitHub\mcm1957\ioBroker.test230706> npm pack --dry-run
E:\GitHub\mcm1957\ioBroker.test230706> git status --short --untracked-files=all
Couldn't check .gitignore: Error: Command failed: git status --short --untracked-files=all
fatal: not a git repository (or any of the parent directories): .git

Installing js-controller and admin...
E:\GitHub\mcm1957\ioBroker.test230706\.dev-server\default> npm install --loglevel error --production

create-adapter.json.zip

Support for remote dev-server

As discussed in a chat with @UncleSamSwiss, it would be nice if dev-server can be used remote.
This would be very useful especially for embedded systems (like a Raspberry Pi). So you can run your dev environment on your (powerfull) desktop PC and test the adapter on the remote embedded system, maybe with special hardware attached.

Possible setup and run

dev-server setup --remote [email protected]
dev-server watch --remote [email protected]

The files which will be included in the npm package should be synced to the remote on change.

Debugging

For debugging it should be possible to attach a debugger (like vscode-js-debug).

The adapter node process has to be started with the additional arguments:

  • --inspect-brk=0.0.0.0:9229 or --inspect=0.0.0.0:9229 (maybe with -brk, the IP and the port configurable)
  • --nolazy (needed for correct breakpoint locations at startup)

For TypeScript adapters, "inlineSourceMap": true have to be set in tsconfig.json.
Using the "normal" "sourceMap": true option, I wasn't able to get the sourcemaps running for remote debugging. The breakpoints are set in the remote process, but not mapped back to the sources in VSCode and only the build js files were shown.

To check the VSCode debugger session setup, you may run "Debug: Create Diagnostic Information for Current Session" from the command palette and then select "Why my breakpoints don't bind". If there are three green check marks you are fine.

The source files (from src/) are not needed on the remote system. The mapping from the build files to the source files is performed in VSCode.

The launch.json to attach the debugger may look like:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "protocol": "inspector",
      "request": "attach",
      "name": "Attach Remote",
      "address": "192.168.1.50",
      "port": 9229,
      "smartStep": true,
      "skipFiles": [
        "<node_internals>/**"
      ],
      "outFiles": [ // for TypeScript adapters
        "${workspaceFolder}/build/**/*.js"
      ],
      "sourceMaps": true, // for TypeScript adapters
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/opt/iobroker/node_modules/iobroker.canbus", // full path to remote adapter directory
      "trace": true
    }
  ],
}

localRoot and remoteRoot are needed for correct mapping of the remote URLs provided by the debugger to the locals URLs in your workspace.
address and port may be defined using the ${inputs:xxx} syntax for a more flexible setup.

dev-server does not close started adapters gracefully or at all!

My Adapter also creates an express server to receive data from various sources.

When I want to use dev-server with it I hope my understanding is right to use dev-server watch to see updates.

Nevertheless, after starting once the adapter stays alive even if you stop watch with ^C. In background I see the node-process with the adapter still running.
I cannot start adapter again (have to use netstatat to find out process number using my port of my adapter server and taskkill to kill the task.

Otherwise changes work and adapter get restarted. Problem is only if I need to change something in the config and want to re-run Ihave no command to restart server while in watch mode and need to stop him with ^C, but then ....

So please make sure that running adapter is stopped when any of the server modes are stopped by ^C!

Thanks, otherwise running well so far!

defaultNewAcl of system.config is incomplete

When setting up a new dev server, the default acl for object and file are missing. Example:

    "defaultNewAcl": {
      "owner": "system.user.admin",
      "ownerGroup": "system.group.administrator",
      "state": 1636
    }

Not sure if this is a dev server issue or js-controller

Allow to ignore File watching for chosen files

If an adapter uses the node_modules directory of himself to (temporariely) store data then I would like to define those filenames as "Ignore by watcher" because else the adapter anytime restarts on change in watch mode

`dev-server run` stuck waiting for React watch build

$ dev-server run
Using profile default
Using profile name "default"
Using adapter name "react"
D:\reacttest\ioBroker.react\.dev-server\default> node node_modules/iobroker.js-controller/controller.js
Running inside D:\reacttest\ioBroker.react\.dev-server\default
Starting React build
Waiting for first successful React build...
D:\reacttest\ioBroker.react> npm run watch:react

> [email protected] watch:react
> build-adapter react --watch

[...] bunch of ioBroker logs

Compiling React with ESBuild in watch mode...

[...] bunch of ioBroker logs
2022-04-08 16:53:12.549  - info: host.dev-react-DESKTOP-OCULUR0 instance system.adapter.admin.0 started with pid 2600
[watch] build finished, watching for changes...

To reproduce:

[setup] Set default language, currency sign (and country / location ?)

These information are empty after dev-server setup

dev-server/src/index.ts

Lines 1244 to 1252 in 2d1846a

this.log.notice(`Patching "system.config"`);
await this.updateObject('system.config', (systemConfig) => {
systemConfig.common.diag = 'none'; // Disable statistics reporting
systemConfig.common.licenseConfirmed = true; // Disable license confirmation
systemConfig.common.defaultLogLevel = 'debug'; // Set default log level for adapters to debug
systemConfig.common.activeRepo = 'beta'; // Set adapter repository to beta
return systemConfig;
});
}

dev-server stops with syntax error

during installation the dev-server throws an exception. After installation the same issue occurs.
This is a fresh download and install. Unfortunately no version information available.

knherzog@debian:~$ dev-server watch
/home/knherzog/.npm-global/lib/node_modules/@iobroker/dev-server/node_modules/@iobroker/testing/build/tests/integration/lib/dbConnection.js:161
        await this._objectsClient?.destroy();
                                  ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/knherzog/.npm-global/lib/node_modules/@iobroker/dev-server/dist/index.js:31:24)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

Mod: formatted

Start an instance of the DB server to avoid having each CLI command do this over and over

Initial setup of the dev-server is pretty slow because every CLI command (while js-controller isn't running) starts two DB instances, connects to them, performs its command and shuts down the DBs again. It would be much faster to spin up the DB manually, perform all CLI commands (or edit objects directly) and then shut down the DBs before starting the controller.

Here's an example how @iobroker/testing does it:
https://github.com/ioBroker/testing/blob/c30c06c228285811aa05cf58d731493b8565729d/src/tests/integration/lib/dbConnection.ts#L122-L135

https://github.com/ioBroker/testing/blob/c30c06c228285811aa05cf58d731493b8565729d/src/tests/integration/lib/harness.ts#L106-L108

https://github.com/ioBroker/testing/blob/c30c06c228285811aa05cf58d731493b8565729d/src/tests/integration/lib/harness.ts#L265-L275

Allow multiple "profiles" when running dev-server

This will allow us to have different test environments.

The current folder needs to be moved one hierarchy lower (and all files adjusted) when running the new version of dev-server. The newly introduced folder will be called "default".

If there is only one profile (i.e. one folder), it will be used automatically.
If there there are multiple profiles, the user must use the (new) additional parameter (after the command) to choose the profile.
If the user doesn't specify the parameter, he is asked to choose the profile from a list.

A new profile can be created by using dev-server setup <profile-name>. The new name shall only contain ASCII characters, dashes and periods; no other characters (including spaces) are allowed. If the profile already exists, setup works the same way as before: if there is no --force option, it fails.

The new command dev-server profile lists all available profiles (actually just the directory names).

Support for vsCode - launch.json

When creating the directory structure for a new adapter a .vscode directory is created as following:

 Verzeichnis von e:\GitHub\test\ioBroker.test\.vscode

20.07.2022  20:16    <DIR>          .
20.07.2022  20:16    <DIR>          ..
20.07.2022  20:16                71 extensions.json
20.07.2022  20:16               225 settings.json

I suggest to add a template launch.json like this one (as an example)

{
    // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
    // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
    // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch normal",
            "program": "${workspaceFolder}/main.js",
            "args": ["--instance", "0", "--force", "--logs", "--debug"],
            "request": "launch",
            "stopOnEntry": true,
            "console": "internalConsole",
            "outputCapture": "std",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node"
        },
    
        {
            "name": "Launch install",
            "program": "${workspaceFolder}/main.js",
            "args": ["--instance", "0", "--force", "--logs", "--debug", "--install"],
            "request": "launch",
            "stopOnEntry": true,
            "console": "internalConsole",
            "outputCapture": "std",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node"
        },
    

        {
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}",
            "request": "attach",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node"
        }
    ]
}

Please note the line
"outputCapture": "std",

an issue
ioBroker/dev-docs#35

dev-server update fails with error about missing tgz file

Trying to update js-controller using the dev-server update command fails with the following error output:

The culprit seems to be this line in the package.json of the installed iobroker:
"iobroker.lovelace": "file:../../iobroker.lovelace-3.0.1.tgz",
-> i.e. npm searches this file, but it does not exists.

Workarounds are:

  • run npm pack before dev-server update (which creates the file in question)
  • use the symlinks feature (which sadly is not yet documented in the readme?)

I tried to fix it, thinking it would be an easy fix.... but... uhm... changes would need to be bigger than expected.... Basically this line already fails. Moving the lines below that build and install the adapter up, did not help, because the functions seem to delete the tgz file... Maybe that can be prevented somehow? Or the alternative is to create a pack function? But that would leave the tgz file on disk (with probable issues, like users commiting it and so on).

Code changes for widgets are not visible in vis

Hello!

I am currently working on creating a widget for my adapter. On the first day, I was able to see the changes i did in the html and js file, but after some changes, the code I updated in my directory was not updated in the vis. I was using dev-server watch, also tried dev-server upload, but no changes are comming.

"dev-server-watch" is not starting properly

I am developing a new adapter and using the dev server.
This one is installed on Proxmox as a CT and has full 4 CPUs and 1GB Ram.
Ram is round about 400-500 when dev-server is started and CPU is at 15-20% maximum.

Please see attached the log file from iobroker and from dev-server.
Here you have some more output from dev-server --> devserverlog

In the developer starter group the first idea was that maybe the connection is not too slow but maybe to fast because iobroker does not seem to see that the adapter instance was already starting ? Just a guess.

opnsense_log.txt
devserverlog.txt

Support for adapter dependencies

@gaudes tried to use dev-server with an adapter that depends on vis.

The following error was shown:

StartInstance system.adapter.diashow.0: required adapter "vis" not found!

It would be great if we could check for the dependencies and add them during setup.

WebSocket error: Error: connect ECONNREFUSED 127.0.0.1:20426

I wanted to try it again today to see if I can reproduce the error, and there it was already at the first startup from dev-server.

Here is the whole start log dev-server_log.txt
I hope you can do something with it.

When the error occurs, it can also sometimes go away after a few seconds, or you make a change in the main.js so that the dev-server establishes a new connection.

I work on Mac, but I have also had this error on Windows.

Cannot run dev-server after install

I wanted to try dev-server today on my windows-machine but could not manage. got always proxy error on the web page.

I then tried on my notebook and it was working there, so I investigated why it did not load on my dev-PC (Windows 10 updated, Node 14.* latest, ...) was same as on notebook.

I found the reason logging at install logs: On the dev-PC I had an ols version from node-gyp and had to install
npm i -g windows-build-tools again.
It would be good if you mention in your setup readme part to run this install as well.

p.s.: As my system had I do change port but could not by running a new setup, I had to delete the cache directory and run a clean setup. Maybe it would be great to be able change the port after install as well....

Otherwise it seems to work now. well! Good job done!

One other problem arised on further tests but here it migt be also admin 5.0.6 which was installed by default: I use it to test an adapter with my new react-based config which uses index.html and not index_m.html in admin (also "materialize": false
in io-package). Admin does not open config but lists just file in admin, if I switch to reacct-mode of admin-5 it works!

My instructions for debugging via remote

Inspired by the great demand for a suitable setup, I have written down my settings here. This is not an issue but a possible basis for a documentation.
My setting consists of a proxmox-lxc, in which a test adapter was created via Adapter-Creator. The processing is done via ssh from a Windows client via VSC.
First, I stored a 'launch.json' from the example here (ioBroker/create-adapter#1059) in VSC under .vscode. I adjusted this until no more errors were displayed.

{
"version": "0.2.0",
"configurations": [
{
"name": "Launch normal",
"program": "${workspaceFolder}/main.js",
"args": ["--instance", "0", "--force", "--logs", "--debug"],
//"env": {"NODE_PATH" : ".dev-server/default/node_modules"},
"env": {"NODE_PATH" : "${workspaceFolder}/.dev-server/default/node_modules"},
"request": "launch",
"stopOnEntry": true,
"console": "internalConsole",
"outputCapture": "std",
"skipFiles": [
"<node_internals>/"
],
"type": "node"
},
{
"name": "Launch install",
"program": "${workspaceFolder}/main.js",
"args": ["--instance", "0", "--force", "--logs", "--debug", "--install"],
"env": {"NODE_PATH" : ".dev-server/default/node_modules"},
"request": "launch",
"stopOnEntry": true,
"console": "internalConsole",
"outputCapture": "std",
"skipFiles": [
"<node_internals>/
"
],
"type": "node"
},
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
}
]
}

Additionally, I added the following line to the lxc in .bashrc:

NODE_PATH='/home/raschy/ioBroker.raschytest/.devserver/default/node_modules/'

I then started the dev-server with 'run'. Now I could debug via ssh.
Whether all the steps were correct or something could be too much, must be judged by the experts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.