-
Notifications
You must be signed in to change notification settings - Fork 1
/
01-cakeresque.patch
63 lines (54 loc) · 2.24 KB
/
01-cakeresque.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/Console/Command/CakeResqueShell.php b/Console/Command/CakeResqueShell.php
index 45d170c..078dd47 100755
--- a/Console/Command/CakeResqueShell.php
+++ b/Console/Command/CakeResqueShell.php
@@ -514,7 +514,7 @@ class CakeResqueShell extends Shell {
$pidFile = Configure::read('CakeResque.Resque.tmpdir') . str_replace('.', '', microtime(true));
- $cmd = implode(' ', array(
+ $cmdArray = array(
sprintf("nohup %s \\\n", ($this->_runtime['user'] === $this->__getProcessOwner()) ? "" : "sudo -u " . $this->_runtime['user']),
sprintf("bash -c \"cd %s; \\\n", escapeshellarg($libraryPath)),
implode(' ', $envVars),
@@ -537,7 +537,15 @@ class CakeResqueShell extends Shell {
sprintf("php %s \\\n", escapeshellarg($resqueBin)),
sprintf(">> %s \\\n", escapeshellarg($logFile)),
"2>&1\" >/dev/null 2>&1 &"
- ));
+ );
+
+ if ($this->_runtime['Log']['handler'] === "Docker") {
+ array_pop($cmdArray);
+ array_pop($cmdArray);
+ array_shift($cmdArray);
+ $cmdArray[] = "2>&1\"";
+ }
+ $cmd = implode(' ', $cmdArray);
$count = $this->_runtime['workers'];
@@ -547,8 +555,18 @@ class CakeResqueShell extends Shell {
$this->debug(__d('cake_resque', 'Starting worker (' . $i . ')'));
$this->debug(__d('cake_resque', 'Running command : ' . "\n\t " . str_replace("\n", "\n\t", $cmd)));
- $this->_exec($cmd);
+ if ($this->_runtime['Log']['handler'] === "Docker") {
+ $descriptors = [
+ 0 => ['pipe','r'],
+ 1 => ['pipe','w'],
+ 2 => ['pipe','w']
+ ];
+ $proc = proc_open($cmd,$descriptors,$pipes);
+ }
+ else {
+ $this->_exec($cmd);
+ }
$success = false;
$attempt = 7;
@@ -577,6 +595,12 @@ class CakeResqueShell extends Shell {
$ResqueStatus->addWorker($pid, $workerSettings);
+ if ($this->_runtime['Log']['handler'] === "Docker") {
+ while (proc_get_status($proc)['running']) {
+ $str = fread($pipes[$i], 1024);
+ if ($str) $this->out($str);
+ }
+ }
break;
}
}