Launching electron app in a nodejs server


#1

Is it possible to launch an electron app in a nodejs server? My ultimate goal is to run node server.js, and launch 2 or 3 electron apps that can communicate with the server.js via ipc channel.
Right now, I’ve put var electron = require(’./app’) in my server.js, but it doesn’t seem to work as it always says that it can’t find the module app and module browser-window. If I run electron app.js, the app works fine.


#2

Electron has its own version of Node that it depends on, so no, it won’t run in a vanilla Node.js server instance.


#3

I see. Is it likely to create a separate, external server, and make two electron apps listen to it though?


#4

I’m not sure what you’re asking. Are you asking if two different Electron apps could communicate with yet another third process? Sure, that’s totally possible.

I feel like that’s asking “Can two different web browsers connect to the same web server?” though so I assume I’m missing something :grinning:


#5

Yeees, so basically my third process will broadcast messages to the two different electron apps. Could I create a vanila node.js server using socket.io to feed messages to the two electron apps? What would be your suggestion?


#6

I’m wondering why there has to be all of this thick separation? It sounds like all three processes are going to be always running (or at least always running together). If that is the case, then why do they have to be three separate applications? Why not use the Electron main process as the communication hub and multiple renderer processes as the leaves?


#7

Because eventually I would like to have remote control of multiple electron apps via one electron app. The three processes I described is a preliminary prototype


#8

I’d probably use something akin to the Mobile JSON Wire Protocol from Selenium as a base. It appears there is even a Node module for it:


#9

I am actually fairly new to http get post request…any starter kits for a newbie?:sweat_smile:


#10

I’m not familiar with what’s out there and what’s best. You might want to ask in the #electron channel in Slack.