-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Error when trying create binary build of file a .phar from hyperf application #477
Comments
Can you find this file in your packaged phar? (not micro binary, just phar) https://github.com/hyperf/hyperf/blob/master/src/framework/src/Event/BeforeServerStart.php And it would be better if you could provide phar build method. |
Yes, when I run the command directly in the phar file, it recognizes the The library used to build phar was ❯ swoole-cli -d "phar.readonly=0" bin/hyperf.php phar:build --name=hyperf.phar
[DEBUG] [command] Commands registered by Hyperf\Command\Listener\RegisterCommandListener
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Command\Listener\RegisterCommandListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Config\Listener\RegisterPropertyHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\DbConnection\Listener\RegisterConnectionResolverListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ExceptionHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler listener.
[INFO] Creating phar hyperf.phar
[INFO] Adding main package "hyperf/hyperf-skeleton" I followed all the specifications in the hyperf docs, even the part about moving the hallexcosta in github.com/hallexcosta/hyperf-binary via 🐘 v8.3.8 took 3s
❯ sudo swoole-cli hyperf.phar start
[DEBUG] [command] Commands registered by Hyperf\Command\Listener\RegisterCommandListener
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Command\Listener\RegisterCommandListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Config\Listener\RegisterPropertyHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\DbConnection\Listener\RegisterConnectionResolverListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ExceptionHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler listener.
[DEBUG] Event Hyperf\Framework\Event\BeforeMainServerStart handled by Hyperf\Process\Listener\BootProcessListener listener.
[INFO] Worker#0 started.
[INFO] HTTP Server listening at 0.0.0.0:9501
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#1 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#2 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#3 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#4 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#5 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#6 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[DEBUG] Event Hyperf\Framework\Event\OnManagerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[DEBUG] Event Hyperf\Framework\Event\OnStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#7 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener. |
I forgot to ask earlier, how did you compile micro.sfx and php-cli? (Commands and operating system environment used) |
Operation System: PHP CLI in my local machie: https://github.com/swoole/swoole-cli/releases/tag/v5.1.2.0 Command build: |
Try this? https://hyperf.wiki/3.1/#/en/phar?id=precautions I briefly tried hyperf-skeleton locally and seemed to encounter the same error, but it turned out to be a problem with the pid file path, which should be a problem with hyperf itself. |
Yes, I moved the To get to this problem, I needed to adjust the $basePath = str_starts_with(BASE_PATH, 'phar') ? '/tmp' : BASE_PATH; Example: logger.php return [
'default' => [
'handler' => [
'class' => Monolog\Handler\StreamHandler::class,
'constructor' => [
'stream' => $basePath . '/runtime/logs/hyperf.log',
'level' => Monolog\Logger::DEBUG,
],
],
'formatter' => [
....
],
],
];
logs
|
Yes, I moved the runtime folder to I modify the files $basePath = str_starts_with(BASE_PATH, 'phar') ? '/tmp' : BASE_PATH; The flow I followed to get to this problem
|
I reset my settings and cloned the project, downloaded and built it again and now I'm getting an error even though I set the Build command: hallexcosta in static-php-cli on main [?] via 🐘 v8.2.13 took 9s
❯ spc micro:combine ../../hallexcosta/hyperf-binary/hyperf.phar -O ./my-hyperf-app
_ _ _ _
___| |_ __ _| |_(_) ___ _ __ | |__ _ __
/ __| __/ _` | __| |/ __|____| '_ \| '_ \| '_ \
\__ \ || (_| | |_| | (_|_____| |_) | | | | |_) |
|___/\__\__,_|\__|_|\___| | .__/|_| |_| .__/ v2.2.4
|_| |_|
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 68918384 bytes) in /home/hallexcosta/local/github.com/crazywhalecc/static-php-cli/src/SPC/command/MicroCombineCommand.php on line 89 |
The memory limit issue you mentioned is spc bug (the micro and phar file is too large), and I will fix it later. And I'm searching and testing hyperf packaging command now. |
I tried hyperf locally, checked the source code, and also tried to package a pure swoole application. Only the hyperf package had this problem. Maybe the problem is caused by hyperf itself. We need to hand it over to the hyperf author to check the problem. |
Hi @crazywhalecc! I have a new problem with build
New phpmicro update resolved the initial error from issue #468, but now I'm getting a new error.
I followed the instructions to remove the
buildroot
andsource
folders and runbin/spc del-download micro && bin/spc download micro
However, when I try to run the binary with
./my-binary
it shows the hyperf commands normallyNow, if I actually try to run the server with the
./my-binary start
command, it shows error logsThe text was updated successfully, but these errors were encountered: