Skip to content

Commit bdf7557

Browse files
committed
fix dir in go_build directive.
1 parent ba1f10f commit bdf7557

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

publish/gotask.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
],
2121
'go_build' => [
2222
'enable' => false,
23-
'command' => sprintf(
24-
'go build -o %1$s/bin/app %1$s/gotask/cmd/app.go',
25-
BASE_PATH
26-
),
23+
'workdir' => BASE_PATH . '/gotask',
24+
'command' => 'go build -o ../bin/app cmd/app.go',
2725
],
2826
'pool' => [
2927
'min_connections' => 1,

src/Listener/OnMainWorkerStartListener.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ public function listen(): array
4747
public function process(object $event)
4848
{
4949
Coroutine::create(function () {
50-
$process = ProcessCollector::get('gotask')[0];
51-
$sock = $process->exportSocket();
50+
$processes = ProcessCollector::get('gotask');
51+
if (empty($processes)){
52+
return;
53+
}
54+
$sock = $processes[0]->exportSocket();
5255
while (true) {
5356
try {
5457
/* @var \Swoole\Coroutine\Socket $sock */

src/Process/GoTaskProcess.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ public function isEnable(): bool
4848
public function bind(Server $server): void
4949
{
5050
if ($this->config->get('gotask.go_build.enable', false)) {
51+
chdir($this->config->get('gotask.go_build.workdir',BASE_PATH.'/gotask'));
5152
exec($this->config->get('gotask.go_build.command'), $output, $rev);
5253
if ($rev !== 0) {
5354
throw new GoBuildException(sprintf(
5455
'Cannot build go files with command %s: %s',
5556
$this->config->get('gotask.go_build.command'),
56-
$output
57+
implode(PHP_EOL, $output)
5758
));
5859
}
5960
}

0 commit comments

Comments
 (0)