0

I'm trying to launch a julia program from a drupal website (running on xampp for Windows), it needs to run asynchronously in the background while the php script continues execution. This is the code I'm trying to use:

$juliaFile =  escapeshellarg(DRUPAL_ROOT . '/sites/all/modules/tsap/Modeling/runme.jl');
$cmd = "start /B julia $juliaFile";
pclose(popen($cmd, 'r'));

This code works perfectly if I run it through a command line php script, but it doesn't work when it runs through apache, however, the next bit of code works both from command line and from the webserver (The only difference is running a php script instead of a julia program)

$phpFile =  escapeshellarg(DRUPAL_ROOT . '/sites/all/modules/tsap/Modeling/runme.php');
$cmd = "start /B php $phpFile";
pclose(popen($cmd, 'r'));

I've also tried calling the first block of code within a php file that gets execute by the webserver, which also succeeds from the command line, and fails when the server attempts to execute it.

I also get issues using backtick operators and exec() (they block on the call) and using COM::run() results in the same issue as pclose(popen())

Does anyone have any ideas for getting the julia call to work?

Thanks for your time

LF00
  • 27,015
  • 29
  • 156
  • 295
Velvacaine
  • 103
  • 7

1 Answers1

2

add the '&' end of your command, which put the command in the cackground.

You also can use proc_open() to run the command background. You also refer the post of mine that use the proc_open() to run commands background.

Community
  • 1
  • 1
LF00
  • 27,015
  • 29
  • 156
  • 295
  • As far as I know, & is not available on windows, and start /B is the alternative, at any rate I tried it and it caused both the julia and php versions to fail. I also tried using proc_open and proc_close, which resulted in the same behavior as popen and pclose, i.e. worked for a background php process but not a background julia process. – Velvacaine Jan 01 '17 at 01:05
  • If this, it's not caussed by the subprocess caller function. It's someother reasons. – LF00 Jan 01 '17 at 01:11