frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Can I run frankenphp with supervisor?

Open kilwir76 opened this issue 1 year ago • 19 comments

Describe you feature request

I'd like to be able to run daemon jobs via supervisor.

Is this possible or not?

I've tried, but I can't run supervisor with frankenphp, even though it's installed in a Dockerfile.

kilwir76 avatar Mar 07 '24 09:03 kilwir76

Yes, for instance Laravel Sail runs FrankenPHP using supervisord: https://laravel.com/docs/10.x/octane#frankenphp-via-laravel-sail

dunglas avatar Mar 07 '24 12:03 dunglas

i need to run without laravel sail + octane. Its possible ?

kilwir76 avatar Mar 07 '24 19:03 kilwir76

Definitely!

dunglas avatar Mar 07 '24 21:03 dunglas

i need to run without laravel sail + octane. Its possible ?

You can see the docs (link) to install supervisor. Something like this:

Dockerfile

FROM dunglas/frankenphp

RUN apt update && apt install supervisor

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

supervisord.conf

[program:octane]
command=php /app/artisan octane:frankenphp --host=127.0.0.1 --port=80 --admin-port=2019 --workers=16

sneycampos avatar Mar 10 '24 16:03 sneycampos

@kilwir76 solved your problem? could you close the issue? :)

sneycampos avatar Mar 14 '24 13:03 sneycampos

Thanks ! yes sorry for the wait

kilwir76 avatar Mar 31 '24 16:03 kilwir76

its a same fonctionnality on symfony ?

kilwir76 avatar May 23 '24 20:05 kilwir76

its a same fonctionnality on symfony ?

Yes. you only need to set your entrypoint command in supervisord configuration.

Supervisor is a process control system. It's not exclusive for laravel or anything. You can control any command with.

sneycampos avatar May 23 '24 21:05 sneycampos

What would be the supervisor command to run a Laravel app in the same way as the default Frankenphp image does? (without Octane)

For instance, does the base image do more than something like this:

[program:frankenphp]
directory = /srv
command=/usr/local/bin/frankenphp run --config /etc/caddy/Caddyfile

Does it run in worker mode by default, and how to run in worker mode with supervisor?

thdebay avatar Aug 02 '24 14:08 thdebay

Just wondring is there benefits of running frankenphp in supervisor than doing an entrypoint like this ENTRYPOINT ["php", "artisan", "octane:frankenphp", "--caddyfile=/app/Caddyfile"] with restart: always in docker service 🤔 . I think the entrypoint is simple and achieve same need as running in supervisor.

kitro avatar Oct 14 '24 18:10 kitro

Supervisor is indeed useless if you're using Docker Compose.

dunglas avatar Oct 14 '24 20:10 dunglas

Supervisor is indeed useless if you're using Docker Compose.

Why useless? There are objectives that can benefit from it, such as running Messenger workers. Or does FrankenPHP somehow replace Supervisor role in that context?

janklan avatar Feb 18 '25 03:02 janklan

FrankenPHP doesn't, but Docker Compose does: https://stackoverflow.com/a/57564372

dunglas avatar Feb 18 '25 06:02 dunglas

Why useless?

Why run a supervisor on a supervisor?

withinboredom avatar Feb 18 '25 18:02 withinboredom

@kitro For me the benefit was mainly to handle all the processes required by my application in the same way (frankenphp, horizon, reverb...) without extracting these services to separate containers

thdebay avatar Feb 18 '25 19:02 thdebay

@kitro For me the benefit was mainly to handle all the processes required by my application in the same way (frankenphp, horizon, reverb...)

But you can run each "process" as a service in docker compose, like this:

Image

My comment was before your edit but still with same opinion about to have multiple services instead one with supervisord

sneycampos avatar Feb 18 '25 19:02 sneycampos

Why useless?

Why run a supervisor on a supervisor?

TL;DR I misunderstood @dunglas's comment. He's talking about it being useless to use Docker compose to start Supervisor that manages FrankenPHP. I agere with that, that's pointless.

For context, I found this topic when I was trying to figure out how to run supervisor inside a dedicated FrankenPHP container where the user was not root. I was running into some permission issues (now solved), so I started searching, and found this.

We run supervisor next to the frankenphp process to manage additional background jobs. Locally, we use Docker compose to start the FrankenPHP container. That's where my confusion with "Supervisor is indeed useless if you're using Docker Compose." started.

janklan avatar Feb 18 '25 21:02 janklan

But you can run each "process" as a service in docker compose, like this:

Image

My comment was before your edit but still with same opinion about to have multiple services instead one with supervisord

@sneycampos I understand your point, thank you for taking the time to explain. I think you're right, your approach is better and I will look into it, maybe I will get rid of supervisor in my setup as well.

thdebay avatar Feb 19 '25 06:02 thdebay

@sneycampos I understand your point, thank you for taking the time to explain. I think you're right, your approach is better and I will look into it, maybe I will get rid of supervisor in my setup as well.

I used to run my apps with supervisor too, its ok, but since we are using docker-compose we really don't need supervisor

another project uses the same approach (queue, scheduler, horizon, etc)

sneycampos avatar Feb 19 '25 10:02 sneycampos