Closed freeman42x closed 4 years ago
The two options I know of thus far are:
callProcess
]() at most)
forkIO (Turtle.proc <nwjs)
?)concurrently
to spawn both the NW.js and JSaddle process simultaneously
Chances are both will require extra dependencies, but:
async
is a well-known package and concurrently
offers proper exception and other OS resource handlingSo I'm not sure which one to pick.
[1]: concurrently :: IO a -> IO b -> IO (a, b)
@alter2000 Use Turtle
please for spawning the processes in the correct order: main server and after that start NW.JS
So:
NW.JS
in a blocking manner.If we want to explicitly wait until the webserver is up, then we'll need to add an MVar to the mix to act as a binary semaphore. If we're doing that, we might as well use race
which does that and the rest of the error handling for us. If what's needed is:
then this is a job for an MVar, since standard green threads (from forkIO
and similar) can't be waited on or somehow joined until the whole process is shut down from main. This might not be an issue since everything starts and ends in main either way.
Related: we have to spawn a new thread before calling either blocking action (Turtle.proc
or JSaddle.run
), then spawn the blocking action itself. Since we can't wait without a semaphore, I decided to spawn the new thread, then run NWJS.
@alter2000 I trust you to make the best choice on this matter 💖
forkIO
orConcurrently
'd thenw .
thing through the main process