Automating arduino-cli daemon call

Hi, so all I'm trying to do is to automate the arduino-cli daemon call, that starts off the grpc server.

I've tried doing this in C++ with the system() function found in cstdlib, I've also tried doing it in Node.js with the child_process module. It sounded quite easy, but I've run into the same error on both tests: as the daemon call never ends, in C++ this causes the program to stop and run idle at the system("arduino-cli daemon") call, and in js (because of it's asynchronous nature) the grpc calls are run before the server seems to be set up, causing undefined behaviour. If I force the command line call to run synchronously, I get the same results as in C++.

At this point, I must be doing something completely wrong. Is there any way I could automate the arduino-cli daemon call from within the same program as the grpc client? Otherwise, is there any other alternative that would automate the daemon call?