Running Shell in Controller in Background

Hello,
Is there a way to run Shell in Controller, in the backgroud?
So my app don’t need to wait shell execution to continue.

Thanks

Possibly there will be a for-sure answer from someone else. But I’ve been considering this problem and this is what I am going to try:

Core problem as I see it

Any call to the desired process will wait until it gets a response.

Proposed solution

Make the call register the details of its request in some repository; a db record, cache or log. The return from the process then is the response reporting the result of the save request and it returns immediately.

Then, the external process runs as a cron job. It looks for and processes any requests it find stored.

Hi,
Thanks for your help.
I did exactly as you said.
That’s nice, solved my problem.

Thanks.

It’s possible to make asynchronous calls to a URL, or launch a background process using tools like exec, which will go off and do their work disconnected from any need to respond. But the cron process that @dreamingmind has described “feels” better to me in many ways, and is how I structure all such needs that I have. Most importantly, if the process fails (e.g. due to some exception), you haven’t removed the record yet from the database, so it will just be tried again the next time it runs (and maybe you can fix any bugs in the meantime). With an asynchronous process, if it fails, it just fails, and there’s no way to retry it.