AToMPM / atompm

A Tool for Multi-Paradigm Modeling
https://atompm.github.io/
GNU Lesser General Public License v3.0
22 stars 15 forks source link

Launch python transformation engine as subprocess of nodejs? #145

Open joeriexelmans opened 2 years ago

joeriexelmans commented 2 years ago

Hi,

I see that the "launch" script starts both a nodejs process and a python process in parallel. From what I understand, the nodejs process, which is the "main" process, needs the python process, but not the other way around, so wouldn't it be better to launch the python process as a child process from nodejs? In this way, the AToMPM backend can be understood as a single nodejs process, and killing it will also kill the python process. It will also make it unnecessary to have a complex launch script.

Best regards, Joeri

BentleyJOakes commented 2 years ago

Hi Joeri. Thanks for the idea! I think that's its a good one, and I'll try to find some time to implement it, unless you want to make a pull request. The only two concerns would be:

joeriexelmans commented 2 years ago

Hi Bentley,

A very basic (not addressing your concerns), and usable implementation can be achieved by adding the following 2 lines at the end of httpwsd.js:

const childProcess = require('node:child_process');
childProcess.spawn('python', ['mt/main.py']);

About your concerns:

Anyway, when I look at the source code of the Python script, I don't see any flags that can be set. So the only remaining concern is selecting a specific Python version. This can also be achieved by passing a modified PATH environment variable to NodeJS, containing the right python version.

If you agree with these points, I'm willing to implement this feature and create a pull request.