Kunstmaan / KunstmaanBundlesCMS

An advanced yet user-friendly content management system, based on the full stack Symfony framework combined with a whole host of community bundles. It provides a full featured, multi-language CMS system with an innovative page and form assembling process, versioning, workflow, translation and media managers and much more.
https://kunstmaancms.be
MIT License
402 stars 186 forks source link

Shell helper doesn't work on Mac OSX #931

Closed henrypenny closed 6 years ago

henrypenny commented 8 years ago

I'm on OSX 10.10.5 and the Shell helper isn't working as expected.

I've removed nohup from:

vendor/kunstmaan/bundles-cms/src/Kunstmaan/UtilitiesBundle/Helper/Shell/Shell.php:22

and this solves it for my setup. Is there a good way to detect if its running on Mac and put a switch in place?

mlebkowski commented 8 years ago

You can override this utility in your application.

class OsxShellHelper extends Shell {
    public function runInBackground($command, $priority = 0) {
       // custom logic
    }
}

And in your config.yml:

parameters:
   kunstmaan_utilities.shell.class: OsxShellHelper
whitewhidow commented 8 years ago

perhaps we can check if nohup is present on the system, by dong something like this:

    $try = shell_exec("nohup date");
    if ($try !== null) {
        //nohup is working 
    } else {
        //nohup is not working
    }
henrypenny commented 8 years ago

@whitewhidow Feature detection might be a little more robust?

whitewhidow commented 8 years ago

@henrypenny what exactly do you mean by 'Feature detection' ?

henrypenny commented 8 years ago

As per your suggested solution: testing whether a given feature (nohup) is available as opposed to assuming that OSX doesn't have it. Might there be other OSs without nohup? Or perhaps someone will add it via homebrew in the future.

wesleylancel commented 8 years ago

It seems my OSX does have nohup. Maybe just test with which nohup?

whitewhidow commented 8 years ago

yep that seems like a nice solution ..

kimausloos commented 8 years ago

The use of which for this kind of thing should be avoided for various reasons, there are alternatives though: http://stackoverflow.com/a/677212

delboy1978uk commented 6 years ago

We don't need nohup. If we use popen() or proc_open() to run the command, then the process is already backgrounded :-) http://php.net/manual/en/function.popen.php http://php.net/manual/en/function.proc-open.php

Numkil commented 6 years ago

The problem should be resolved in master branch. Instead of using shell_exec we are now using the Symfony Process object. Process does use proc_open as mentioned in the above comment. This completely negates the necessity for nohup and removes any platform specific code.