Giter Club home page Giter Club logo

Comments (3)

chebureque avatar chebureque commented on September 24, 2024 4

One way you can run those processes in background is to configure background middleware like this:

'commandBus' => [
    'class' => 'trntv\bus\CommandBus',
    'middlewares' => [
        [
            'class' => '\trntv\bus\middlewares\BackgroundCommandMiddleware',
            'backgroundHandlerBinary' => '/usr/bin/php',
            'backgroundHandlerPath' => '@app/yii',
            'backgroundHandlerRoute' => 'background-bus/handle',
            'backgroundHandlerArguments' => ['&']
        ]
    ]
]

In my case that helped to run commands in background from both web and console apps.

from yii2-command-bus.

comradefuzz avatar comradefuzz commented on September 24, 2024 3

I guess that's because of symfony's Process component when running async is using proc_open. That means that if master process ends all of it's child processes will be killed too.
In this case I suggest using exec("{$binary} {$binaryArguments} {$path} {$route} {$arguments} &") instead of $process->start() (see CommandMiddleware). Ampersand allows to run system command in detached mode so master process cannot affect it even when stops or being killed.

from yii2-command-bus.

hellosimple avatar hellosimple commented on September 24, 2024

I use comradefuzz's solution, using exec("{$binary} {$binaryArguments} {$path} {$route} {$arguments} &") instead of $process->start(), work for me.
Thanks all of you! Great help for me!

from yii2-command-bus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.