Elixir or Phoenix integration with Node JS

Hi! I am new to elixir and I am realy love it, this language is simply amazing. My question is this
I have existing Electron app, that contains a bunch of node js scripts. Basically, what I am doing is browser automation via playwright (filling forms with data => save result => display report to user) and what I want is parallel execution of those scripts. How can I create kind of “control” elixir app for my node scripts?And how can I connect it to my existing electron interface.
The flow that I want to achieve: User clicks on button => electron app somehow communicate with elixir app => elixir app starts node js instance 1; User clicks again => electron communicate with elixir => elixir starts node js instance 2… etc

Hello and welcome,

I never tried playwright, but hound can probably do the same.

You can use phoenix npm package in Electron if You want to support Phoenix channels, or You can define an API.

For the rest, You might find OTP useful.

Thanks for quick reply. So, there is no “easy” way to run a bunch of node js scripts inside of elixir? I cannot grasp how this should work, As I understand you correctly “support Phoenix channels” means that we can connect them via websockets, but is this realy the only way? My main concern is to run a node js scripts from elixir “shell” app, because I will not rewrite all my playwright scripts to something like hound.

Sorry, I thought You were speaking of Phoenix, but it’s not the case…

You have different ways to communicate with the Electron application, just tell how You want to do it.

It’s also possible to run external program, You just need to be careful not to bring the VM down.

https://hexdocs.pm/elixir/System.html#cmd/3

This is the picturse that should clarify what I want



Do not misunderstand me, right now everything works without elixir and it works fine, but what I want is to test and kind of play with elixir’s parallelism ability. Any simple way is ok for me, I am not an expert after all.
1 Like

You should probably look into ports.

https://hexdocs.pm/elixir/Port.html

https://elixirschool.com/blog/til-ports/

1 Like

Thanks, seems like this is exactly what I need

Could also try this for calling node from elixir.

2 Likes

Thanks Sir!

So @MihailPertsev have you ended up using Playwright? If so, which approach did you choose and how did it go?

1 Like

I ended up with pure NodeJS solution via generic-pool - npm for concurrency. Yes, I am using Playwright because I need to execute some code inside browsers… So, no Elixir here at all.

1 Like

I have tried this out, but getting an error :

{:error,
 "Cannot find module ....}

What should the name of the module be?