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

[🐛 BUG]: Basic example does not work #1819

Closed
1 task done
suityou01 opened this issue Dec 21, 2023 · 7 comments
Closed
1 task done

[🐛 BUG]: Basic example does not work #1819

suityou01 opened this issue Dec 21, 2023 · 7 comments
Assignees
Labels
B-bug Bug: bug, exception
Milestone

Comments

@suityou01
Copy link

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

I followed the example

Version (rr --version)

2023.3.8

How to reproduce the issue?

Create a dockerfile like so

FROM ghcr.io/roadrunner-server/roadrunner:2023.3.8 AS roadrunner
FROM php:8.2-cli as phpbuild

RUN apt-get update && apt-get install -y \
    zip \
    iputils-ping

COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr

# Install composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && mv composer.phar /usr/local/bin/composer

# Install php dependencies
RUN docker-php-ext-install sockets

FROM phpbuild

WORKDIR "/app"

# USE THE RR
COPY .rr.yaml .
COPY worker.php .
COPY composer.json .

RUN composer install

EXPOSE 80

CMD rr serve -c .rr.yaml

Create an .rr.yaml file

version: '3'

rpc:
  listen: tcp://127.0.0.1:6001

server:
  command: "php worker.php"

http:
  address: "0.0.0.0:8080"

logs:
  level: error

Create a composer file

{
    "require": {
        "spiral/roadrunner-cli": "^2.6"
    }
}

Create a php file

<?php

use Spiral\RoadRunner;
use Nyholm\Psr7;

include "vendor/autoload.php";

$worker = RoadRunner\Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();

$worker = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

while ($req = $worker->waitRequest()) {
    try {
        $rsp = new Psr7\Response();
        $rsp->getBody()->write('Hello world!');

        $worker->respond($rsp);
    } catch (\Throwable $e) {
        $worker->getWorker()->error((string)$e);
    }
}

Run it.

Relevant log output

handle_serve_command: Function call error:
	serve error from the plugin *http.Plugin stopping execution, error: static_pool_allocate_workers: WorkerAllocate: EOF
@rustatian
Copy link
Member

Hey @suityou01 👋
I think that you also need spiral/roadrunner-worker and spiral/roadrunner-http packages. You may try to execute a regular php command, like php worker.php and you'll see the reason of EOF error. Unfortunately, when starting child process and it exists on some initial error, there are no errors except just EOF.

@suityou01
Copy link
Author

Hi @rustatian thank you I will try this. The bug is in the documentation then?

@rustatian
Copy link
Member

Probably. Please point me where did you find this example, and I'll double-check and fix it.

@suityou01
Copy link
Author

suityou01 commented Dec 21, 2023

@suityou01
Copy link
Author

This fixed my issue. Thanks.

@rustatian
Copy link
Member

This fixed my issue. Thanks.

Cool 👍 I'll add missing packages to the README and enjoy RR ❤️

@rustatian rustatian changed the title Basic example does not work [🐛 BUG]: [🐛 BUG]: Basic example does not work Dec 21, 2023
@rustatian
Copy link
Member

Docs have been improved: b707643. Thanks, @suityou01 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-bug Bug: bug, exception
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants