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

Add design note for standalone Node-RED #30

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kazuhitoyokoi
Copy link
Member

I added design node about standalone Node-RED (Electron version of Node-RED).

| ---------------------------- | ----- |
| editorTheme.projects.enabled | true |

If `~./node-red/` directory already has `settings.js` file which was created by common Node-RED, the standalone Node-RED uses it without overwriting the file to avoid changing the current environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it even use the ~/.node-red directory if it is self contained ? If someone already has Node-RED installed should this interact with it or not ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you wrote, I think that there is no need to interact with the normal Node-RED environment. I changed it to ~/.node-red-standalone directory for the standalone environment. Let me know if there is another appropriate name for the directory.


The standalone Node-RED behaves as IDE application like VS Code or Eclipse.
Therefore, users may want to switch multiple projects for various environments on their single computer.
Additionally, they need git functionality as default to proceed with team development or backup their flows.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so would this also install git ? Or is git a prereq ? Or should it autodetect and not enable projects etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If installer support to install git command, we need to add different handlings for Windows, macOS, Linux environments. Therefore, I think that prereq and auto-detection are suitable for the project feature on the standalone Node-RED.

(To realize this functionality, The event log UI in Node-RED core requires ”Open in new window” button which is same as debug tab)

### Runtime
The Node-RED runtime will be executed when the standard Node-RED starts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it always try to run a flow ? last opened flow ? Or should it always start in "safe mode" - as this is now more of an IDE model.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. "safe mode" is natural in an IDE model. I added the text about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree. It really depends how far down the IDE model you want to go.

A full IDE like model would let you open up multiple different flow files, save them separately, run more than one... is that the type of model we want? Until we've set out the basic scope of the IDE, then we simply cannot start discussing individual details about the implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knolleary Thank you for your comments. I added the scope of the standalone Node-RED. Could you review it?


- Windows: C:\Users\\< User name >\AppData\Roaming\node-red\logs\file.log
- macOS: ~/Library/Logs/node-red/file.log
- Linux: ~/.config/node-red/logs/file.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use system log files so linux can autoclean them up ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto clean by OS will be useful. I changed the file path to /var/log/node-red.log. winston-syslog module seems to be able to store the log data to this directory.


- Windows (msi)
- macOS (dmg)
- Linux (tar.gz)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

electron-builder can build deb and rpm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, electron-builder can build various types of binaries. To reduce our tasks to check all binaries in every release, I wrote three major binaries. I would like to suggest documentation about how to build other binaries like deb and rpm.

@knolleary
Copy link
Member

I've been doing some thinking about some of the basic design decisions to be made around Standalone Node-RED. The goal here is to provide a good user experience that is more than simply putting Node-RED in a native desktop window. I've also identified some technical issues with Electron that need to be addressed from the start.

1. Using Worker threads to run Node-RED within Electron

We know that node.js is single threaded. When running Node-RED today, you have the runtime using the node.js process and the editor is running in its own browser process. They are separate processes with no connection other than the editor's http calls to the runtime.

Inside Electron, you have the Main thread and the Renderer thread used to update the BrowserWindow. Whilst they are separate threads, I have read a number of posts that warn against putting heavy workloads on the Main thread as it can block the IPC between the Main thread and Renderer and impact the UI performance. (reference)

The recommended approach is to put the heavy workloads in Worker thread.

This opens up another interesting possibility...

2. Run multiple Node-RED instances

This isn't a Version One feature, but I think it's something to have in the design in order to make some right choices at the start.

I can picture the Node-RED IDE providing a UI similar to Slack, where you can have multiple Node-RED instances in the application. Each instance would be a fully self-contained Node-RED instance, with its own userDir and a unique port number. This will make it easy for the user to spin up multiple, separate instances of Node-RED.

It should also be possible to add a remote instance that is already running elsewhere. For example, a user installs Node-RED on a Pi using our script. They then open up Node-RED IDE on their desktop and "add" the raspberry pi instance to the workspace.

3. Installing new nodes

I don't think I've seen this discussed: how can the user install new nodes? Electron doesn't include npm (as far as I can see) - so would need to include it ourselves. How would we do that?

We then have the issue of installing modules with native modules. This page in the docs explains what is required to do that - https://www.electronjs.org/docs/tutorial/using-native-node-modules.

4. First run experience

The first time the user runs the Node-RED Desktop app, we should prompt the user for any first-run configuration that is needed.
If we go down the route of the supporting multiple instances, it could prompt the user to either create their first Node-RED instance, or to connect to an existing one.

If they create their first instance, we can ask a number of questions to preconfigure it. For example, configuring user security to encourage a secure-by-default approach. I'm sure there will be other config options we could consider here.

5. Editing the settings file

Following on from the previous suggestion, the user ought to be able to customise the runtime further via the Desktop app. I don't mean by editing the settings.js file, but via proper a proper UI experience.

@dceejay
Copy link
Member

dceejay commented Dec 3, 2020

Yes - 4 and 5 were what I was getting at with the Refocus Issue - I think a good consistent install / customisation experience would help avoid a lot initial issues.

1 & 2 - Interesting thought - and yes a cleaner separation would make sense. I suppose first up it could make the main app more of a "project manager" and just switch between (non-running) projects - or does that head too much towards being a VScode plugin ?

3 is potentially v. hard - there seem to be lots of issues around various packages (mainly with native code not cross compiling) or otherwise being incorrect engine versions that stop things working.

@knolleary
Copy link
Member

If we can't solve 3 then we shouldn't do this work - or at least, we shouldn't use Electron. There is little benefit making it easier to install Node-RED if you can't also install nodes.

@kazuhitoyokoi
Copy link
Member Author

Thank you for the discussion.

  1. Because the npm is provided as an npm module, we can add it to dependencies in package.json of node-red-desktop (node-red-installer). To support it, Node-RED core needs some modifications to call npm module. And we need to consider handling when updating the Node.js version in electron. I think that the node-red-installer needs to have npm rebuild handling for installed nodes under the .node-red directory.

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

Successfully merging this pull request may close these issues.

3 participants