spiral-modules / roadrunner-binary

💾 High-performance PHP application server, load-balancer and process manager written in Golang. RR2 releases repository.
MIT License
44 stars 25 forks source link

[BUG] Have a problem to VirtualBox shared folder in `spiral/roadrunner-laravel` #33

Closed Alexei007 closed 3 years ago

Alexei007 commented 3 years ago

I tried this code:

./rr -c .rr.yaml serve

I expected to see this happen: The program is running normally

Instead, this happened: image

The version of RR used: 2.0.3

The operation system used: cenots7

RR configuration file content:

http:
  address: 0.0.0.0:8080
  pool:
    num_workers: 8
    max_jobs: 0
    supervisor:
      # watch_tick defines how often to check the state of the workers (seconds)
      watch_tick: 1s
      # ttl defines maximum time worker is allowed to live (seconds)
      ttl: 0
      # idle_ttl defines maximum duration worker can spend in idle mode after first use. Disabled when 0 (seconds)
      idle_ttl: 10s
      # exec_ttl defines maximum lifetime per job (seconds)
      exec_ttl: 10s
      # max_worker_memory limits memory usage per worker (MB)
      max_worker_memory: 100
  headers:
    cors:
      allowed_origin: "*"
      allowed_headers: "*"
      allowed_methods: "GET,POST,PUT,DELETE"
      allow_credentials: true
      exposed_headers: "Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma"
      max_age: 600

server:
  command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///var/run/rr-rpc.sock"
  relay: "unix:///var/run/rr-rpc.sock"
  env:
    RR_MODE: http

logs:
  mode: development
  level: debug
  encoding: console
  output: stderr
  err_output: stderr
  channels:
    http:
      mode: development
      level: panic
      encoding: console
      output: stdout

# healthcheck
status:
  address: "0.0.0.0:8090"

reload:
  # sync interval
  interval: 1s
  # global patterns to sync
  patterns: [ ".php" ]
  # list of included for sync services
  plugins:
    http:
      # recursive search for file patterns to add
      recursive: true
      # ignored folders
      ignore: [ "vendor" ]
      # service specific file pattens to sync
      patterns: [ ".php", ".go", ".md" ]
      # directories to sync. If recursive is set to true,
      # recursive sync will be applied only to the directories in `dirs` section
      dirs: [ "." ]

remarks: I can run normally on the cloud server, including centos8 and Ubuntu. The local server is not working properly. spiral/roadrunner-laravel version: 4.0.1. And The CentOS7 of my local machine can run normally, spiral/framework.

rustatian commented 3 years ago

Hey @Alexei007. You have the wrong relay value, it should be in the form of unix://file.sock, in your case - unix://var/run/rr-rpc.sock

rustatian commented 3 years ago

I might be wrong because I guess your socket has the path from the root /var/run/rr-rpc.sock. Could you also try to run your worker separately, because as I see from the logs, there is an error while RR tries to run your worker.

Alexei007 commented 3 years ago

Hey @Alexei007. You have the wrong relay value, it should be in the form of unix://file.sock, in your case - unix://var/run/rr-rpc.sock

Hello, Valery Piashchynski, Thank you for your reply.

It doesn't seem to be a configuration file problem. I test the same code on the local server and the cloud server. The cloud server is running normally, and the local server is running incorrectly.

I use exactly the same project, include . rr.yaml file.

server:
  command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///var/run/rr-rpc.sock"
  relay: "unix:///var/run/rr-rpc.sock"

http:
  address: 0.0.0.0:8080
  middleware: ["headers", "static", "gzip"]
  pool:
    max_jobs: 64 # feel free to change this
    supervisor:
      exec_ttl: 60s
  headers:
    response:
      X-Powered-By: "RoadRunner"
  static:
    dir: "public"
    forbid: [".php"]

image

rustatian commented 3 years ago

@Alexei007 Check the 8080 port in your local env. And try to run worker without RR, not to work with, but to check the problem.

rustatian commented 3 years ago

Also, add these lines to your config:

# RoadRunner internal container configuration (docs: https://github.com/spiral/endure).
endure:
  grace_period: 30s
  print_graph: false
  log_level: error
Alexei007 commented 3 years ago

 Большое спасибо за терпение )

No error reported, relevant process can be found, When running

php ./vendor/bin/rr-worker start

image


When running the code, port 6061 is normal and port 8080 is unused.

image

rustatian commented 3 years ago

Firewall, hm... Do you use a firewall in your local env? If so, could you please try to turn it off and re-run the application (temporary)?

Alexei007 commented 3 years ago

Let me explain, exactly the same project. The cloud server is running normally (centos8 and Ubuntu). The local server, centos7 system, couldn't work normally. At first, I thought it was a system problem, so I tried to install centos8 to run the code. But it still doesn't work, I can't solve the problem. I would like to use RR + laravel in my new project, but the current situation may not work.


Hope Taylor Otwell will bring a surprise next Monday.

image

Alexei007 commented 3 years ago

Firewall, hm... Do you use a firewall in your local env? If so, could you please try to turn it off and re-run the application (temporary)?

It's not a firewall problem, the port is open, and I'm running locally.

rustatian commented 3 years ago

As I see from the error log, that by some reason, RR can't allocate a worker at your local system. This is definitely some local system issue. Might be some outdated package or something else. If you paste here the steps on how to reproduce your issue with the *.php worker I'll try to help you.

tarampampam commented 3 years ago

Hi @Alexei007! Could you please try to change relay from unix:///var/run/rr-rpc.sock to unix:///tmp/rr-rpc.sock or tcp://127.0.0.1:6001 (any unused port)?

Alexei007 commented 3 years ago

Many thanks ) You are so handsome )

There is a great possibility that there are some outdated packages, Because there are some restrictions on the Internet in China. And I saw in China's technology forum that many developers couldn't run RR normally and didn't find a solution.

But the question now is how to find out that outdated packages.

Alexei007 commented 3 years ago

Hi @Alexei007! Could you please try to change relay from unix:///var/run/rr-rpc.sock to unix:///tmp/rr-rpc.sock or tcp://127.0.0.1:6001 (any unused port)?

@tarampampam

Thanks for your comment, I tried, That should not be the problem.

This project can run normally on the cloud server.

server:
  command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///tmp/rr-rpc.sock"
  relay: "unix:///tmp/rr-rpc.sock"

http:
  address: 0.0.0.0:8080
  middleware: ["headers", "static", "gzip"]
  pool:
    max_jobs: 64 # feel free to change this
    supervisor:
      exec_ttl: 60s
  headers:
    response:
      X-Powered-By: "RoadRunner"
  static:
    dir: "public"
    forbid: [".php"]
tarampampam commented 3 years ago

...many developers couldn't run RR normally and didn't find a solution.

Sounds very-very strange.. Anyway, could you please to make an attempt to run your application using isolated environment like docker? This tutorial (ru lang; a little bit outdated) can helps you with this.

wolfy-j commented 3 years ago

Have you tried to use pipes relay or TCP relay? Can you post your worker code?

Alexei007 commented 3 years ago

Have you tried to use pipes relay or TCP relay? Can you post your worker code?

Thanks, @wolfy-j . The project can run normally in the cloud server, with exactly the same code. Therefore, It shouldn't be a code problem. It might be some package used by RR that I installed locally is outdated.

I installed it with composer. By the way, My local CentOS can run spiral/framework normally.

composer require spiral/roadrunner-laravel "^4.0"

File: ./vendor/bin/rr-worker

#!/usr/bin/env php
<?php

declare(strict_types=1);

\define('RR_WORKER_START', \microtime(true));

\ini_set('display_errors', 'stderr');

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

$loaded = false;

foreach (['../../..', '../..', '..', 'vendor', '../vendor', '../../vendor'] as $path) {
    if (\is_file($autoload_file = __DIR__ . '/' . $path . '/autoload.php')) {
        require $autoload_file;
        $loaded = true;
        break;
    }
}

if ($loaded !== true) {
    \fwrite(\STDERR, 'Composer autoload file was not found. Try to install project dependencies' . PHP_EOL);
    exit(1);
}

/*
|--------------------------------------------------------------------------
| Find Application Base Path
|--------------------------------------------------------------------------
|
| This file can be located in package `./bin` directory, used as a symbolic
| link or something else. In this case we will try to find application
| base directory using the most obvious application locations.
|
*/

/** @var string|null $base_path */
$base_path = null;

foreach (['../../../..', '../../..', '../..', '..', '../vendor/laravel/laravel'] as $path) {
    if (\is_file(__DIR__ . '/' . $path . '/bootstrap/app.php')) {
        $base_path = (string) \realpath(__DIR__ . '/' . $path);
        break;
    }
}

/*
|--------------------------------------------------------------------------
| Create And Run Console Application
|--------------------------------------------------------------------------
|
| Symfony console component is a nice wrapper around worker CLI options.
|
*/

$app = new \Symfony\Component\Console\Application(
    'RoadRunner worker',
    \Composer\InstalledVersions::getPrettyVersion('spiral/roadrunner-laravel')
);

$app->add(new \Spiral\RoadRunnerLaravel\Console\Commands\StartCommand(
    new \Spiral\RoadRunnerLaravel\Worker(),
    $base_path
));

$app->run();
Alexei007 commented 3 years ago

@48d90782 @wolfy-j @tarampampam

Спасибо за помощь )

I tried to reinstall laravel, RR And PHP, And it works. I'm very confused that I didn't succeed in the same steps I did yesterday, It's really crazy to try so many times these days without solving it.

You are all great, Thank you so much~~~

Alexei007 commented 3 years ago

@wolfy-j @48d90782

Just now, I found out the reasons for success and failure.

I install the CentOS system locally on the visualbox, My projects are usually placed in a shared folder with windows.

What I still don't understand is that my other projects can work normally. Why does this happen to spiral/roadrunner-laravel.

rustatian commented 3 years ago

@Alexei007 Thanks for your investigation :) We will try to reproduce it.