Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 系统支持 #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Windows 系统支持 #65

wants to merge 3 commits into from

Conversation

try-to
Copy link

@try-to try-to commented Aug 11, 2023

用于swoole-cli Windows系统下的使用

go test -v .\server_windows_test.go .\server_windows.go .\common.go .\flag.go .\client.go .\generator.go .\process_windows.go
=== RUN   TestClearAddr
C:\Users\tryto\AppData\Local\Temp\774225308
--- PASS: TestClearAddr (0.00s)
PASS
ok      command-line-arguments  1.051s

hyperf 将go程序打包为.exe 下启动正常

@try-to
Copy link
Author

try-to commented Aug 11, 2023

未改变原代码,原有文件上加了编译条件判断

@try-to
Copy link
Author

try-to commented Aug 11, 2023

go run .\example\sidecar.go -address 127.0.0.1:6001

or

go build -o app.exe .\sidecar.go
.\app.exe -address 127.0.0.1:6001
const ADDR = '127.0.0.1:6001';

run(function () {
    $task = new SocketIPCSender(ADDR);
    var_dump($task->call('App.HelloString', 'Hyperf'));
    var_dump($task->call('App.HelloInterface', ['jack', 'jill']));
    var_dump($task->call('App.HelloStruct', [
        'firstName' => 'LeBron',
        'lastName' => 'James',
        'id' => 23,
    ]));
    var_dump($task->call('App.HelloBytes', base64_encode('My Bytes'), GoTask::PAYLOAD_RAW));
    try {
        $task->call('App.HelloError', 'Hyperf');
    } catch (\Throwable $e) {
        var_dump($e);
    }
    try {
        $task->call('App.HelloPanic', '');
    } catch (\Throwable $e) {
        var_dump($e);
    }
});
swoole-cli .\main.php
string(14) "Hello, Hyperf!"
array(1) {
  ["hello"]=>
  array(2) {
    [0]=>
    string(4) "jack"
    [1]=>
    string(4) "jill"
  }
}
array(1) {
  ["hello"]=>
  array(3) {
    ["id"]=>
    int(23)
    ["firstName"]=>
    string(6) "LeBron"
    ["lastName"]=>
    string(5) "James"
  }
}
string(8) "My Bytes"
object(Spiral\Goridge\Exceptions\ServiceException)#9 (7) {
  ["message":protected]=>
  string(92) "error 'Hyperf, it is possible to return error' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'"
  ["string":"Exception":private]=>
  string(0) ""
  ["code":protected]=>
  int(0)
  ["file":protected]=>
  string(85) "/cygdrive/f/.../gotask/vendor/spiral/goridge/src/RPC.php"
  ["line":protected]=>
  int(123)
  ["trace":"Exception":private]=>
  array(4) {
    [0]=>
    array(6) {
      ["file"]=>
      string(85) "/cygdrive/f/.../gotask/vendor/spiral/goridge/src/RPC.php"
      ["line"]=>
      int(107)
      ["function"]=>
      string(10) "handleBody"
      ["class"]=>
      string(18) "Spiral\Goridge\RPC"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(2) {
        [0]=>
        string(38) "Hyperf, it is possible to return error"
        [1]=>
        int(12)
      }
    }
    [1]=>
    array(6) {
      ["file"]=>
      string(79) "/cygdrive/f/.../gotask/src/IPC/SocketIPCSender.php"
      ["line"]=>
      int(52)
      ["function"]=>
      string(4) "call"
      ["class"]=>
      string(18) "Spiral\Goridge\RPC"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(3) {
        [0]=>
        string(14) "App.HelloError"
        [1]=>
        string(6) "Hyperf"
        [2]=>
        int(12)
      }
    }
    [2]=>
    array(6) {
      ["file"]=>
      string(59) "/cygdrive/f/.../win/.\main.php"
      ["line"]=>
      int(41)
      ["function"]=>
      string(4) "call"
      ["class"]=>
      string(33) "Hyperf\GoTask\IPC\SocketIPCSender"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(2) {
        [0]=>
        string(14) "App.HelloError"
        [1]=>
        string(6) "Hyperf"
      }
    }
    [3]=>
    array(2) {
      ["function"]=>
      string(9) "{closure}"
      ["args"]=>
      array(0) {
      }
    }
  }
  ["previous":"Exception":private]=>
  NULL
}
object(Spiral\Goridge\Exceptions\ServiceException)#10 (7) {
  ["message":protected]=>
  string(94) "error 'panic in go: Test if we can handle panic' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'"
  ["string":"Exception":private]=>
  string(0) ""
  ["code":protected]=>
  int(0)
  ["file":protected]=>
  string(85) "/cygdrive/f/.../gotask/vendor/spiral/goridge/src/RPC.php"
  ["line":protected]=>
  int(123)
  ["trace":"Exception":private]=>
  array(4) {
    [0]=>
    array(6) {
      ["file"]=>
      string(85) "/cygdrive/f/.../gotask/vendor/spiral/goridge/src/RPC.php"
      ["line"]=>
      int(107)
      ["function"]=>
      string(10) "handleBody"
      ["class"]=>
      string(18) "Spiral\Goridge\RPC"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(2) {
        [0]=>
        string(40) "panic in go: Test if we can handle panic"
        [1]=>
        int(12)
      }
    }
    [1]=>
    array(6) {
      ["file"]=>
      string(79) "/cygdrive/f/...//gotask/src/IPC/SocketIPCSender.php"
      ["line"]=>
      int(52)
      ["function"]=>
      string(4) "call"
      ["class"]=>
      string(18) "Spiral\Goridge\RPC"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(3) {
        [0]=>
        string(14) "App.HelloPanic"
        [1]=>
        string(0) ""
        [2]=>
        int(12)
      }
    }
    [2]=>
    array(6) {
      ["file"]=>
      string(59) "/cygdrive/f/.../.\main.php"
      ["line"]=>
      int(46)
      ["function"]=>
      string(4) "call"
      ["class"]=>
      string(33) "Hyperf\GoTask\IPC\SocketIPCSender"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(2) {
        [0]=>
        string(14) "App.HelloPanic"
        [1]=>
        string(0) ""
      }
    }
    [3]=>
    array(2) {
      ["function"]=>
      string(9) "{closure}"
      ["args"]=>
      array(0) {
      }
    }
  }
  ["previous":"Exception":private]=>
  NULL
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant