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

本地Mac命令行启动正常,线上环境Ubuntu启动马上退出 #155

Open
achais opened this issue Mar 22, 2023 · 0 comments
Open

本地Mac命令行启动正常,线上环境Ubuntu启动马上退出 #155

achais opened this issue Mar 22, 2023 · 0 comments

Comments

@achais
Copy link

achais commented Mar 22, 2023

本地Mac命令行启动正常,线上环境Ubuntu启动马上退出!!!

大佬救救我!!
没有任何报错信息!!!
Ubuntu 18.04 64位
PHP 7.2.34
hprose v2.0.40

image

image

TCP Server 代码如下(无关紧要)

<?php

require __DIR__.'/../vendor/autoload.php';

use Hprose\Socket\Server;
use EasyWeChat\Factory;
use Dotenv\Dotenv;

$env = Dotenv::createImmutable(dirname(__DIR__));
$env->load();

$officialAccount = null;

function getOfficialAccount()
{
    global $officialAccount;
    if (empty($officialAccount)) {
        $config = [
            'app_id' => $_ENV['appid'],
            'secret' => $_ENV['secret'],
            'response_type' => 'array',
        ];
        $officialAccount = Factory::officialAccount($config);
    }
    return $officialAccount;
}

function getAccessToken()
{
    try {
        $token =  getOfficialAccount()->access_token->getToken();
        return $token['access_token'] ?? null;
    } catch (\EasyWeChat\Kernel\Exceptions\HttpException $e) {
    } catch (\EasyWeChat\Kernel\Exceptions\InvalidArgumentException $e) {
    } catch (\EasyWeChat\Kernel\Exceptions\InvalidConfigException $e) {
    } catch (\EasyWeChat\Kernel\Exceptions\RuntimeException $e) {
    } catch (\Psr\SimpleCache\InvalidArgumentException $e) {
    }
    return null;
}

function run()
{
    $functions = [
        'getAccessToken',
    ];
    $host = $_ENV['host'] ?? '127.0.0.1';
    $port = $_ENV['port'] ?? '5678';
    $server = new Server("tcp://{$host}:{$port}");
    try {
        foreach ($functions as $func) {
            $server->addFunction($func);
        }
    } catch (Exception $e) {
    }
    $server->start();
}

run();
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

No branches or pull requests

1 participant