Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthortom
     
    Hi,

    In my application, I got the problem that some actions that need to do work in the background and just take several seconds to complete. Now if the user clicks on some link while that work is still unfinished (new action hasn't finished rendering yet), the new link is opened, and in some cases, the background work is then interrupted, which is of course not what I want.

    So I need a way to have the background work really run in the background.

    Is it safe to just pcntl_fork in the middle of any controller action?

    Or is there a way to tell Akelos not to use the busy ActionController instance to serve new requests?

    Regards

    Tom
    •  
      CommentAuthorbermi
     

    I wouldn't use pcntl_fork on Apache as you can eat up RAM easily.

    Action Controller does not have a way to run tasks in the background, but you can try running

    shell_exec("nohup ./script/my_long_lasting_script > /dev/null 2> /dev/null & echo $!");
    

    which might work better.