Error 524 occurs if your origin doesn’t respond to Cloudflare with 100 seconds as you have found.
You’ll need to make the request without using Cloudflare (use a non-proxied hostname, direct IP address of your server, etc), or change your application so the process is started by the request and returns when started, then poll some endpoint if you need to act on its completion.