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

Easy way to start server and worker at once in non-blocking fashion (and/or docs to make this behavior clear) #407

Closed
BWStearns opened this issue Feb 1, 2024 · 5 comments

Comments

@BWStearns
Copy link
Contributor

Description

Right now the default cargo loco start behavior starts just the server. Starting both server and worker with cargo loco start -s starts the server and the worker in such a way that worker jobs block the server. It would be preferable to have a convenient server starting command that had the worker spun up in a separate process.

Additionally it is not clear from the docs that you need to specifically start a separate worker especially for local development.

To Reproduce

Use either cargo loco start -s and get blocking worker behavior or cargo loco start and get no worker behavior.

Expected Behavior

A preferable behavior would be a command that behaves in the same way as cargo loco start & cargo loco start -w & which will interleave the two processes outputs and both will exit on ctl+c.

Environment:

Local

Additional Context

I'm happy to pitch in some effort on the docs. I started looking into how the start commands were generated but I haven't figured out how to adjust the start command or add a new one yet.

@jondot
Copy link
Contributor

jondot commented Feb 1, 2024

to use same-process and async you also need to go to config/development.yaml and change the workermode to BackgroundAsync and then you can start just 1 process with the -s flag.

if you feel like improving the docs we'll be happy to accept a PR 👍

@BWStearns
Copy link
Contributor Author

Is there a way to specify the number of workers btw?

@jondot
Copy link
Contributor

jondot commented Feb 1, 2024

Unlike Ruby and rails background jobs here it’s (mostly) not needed because we have real threads and even more than that real async.

For the async mode the pool is managed by Tokio
For standalone workers with a proper redis queue this governed by a threadpool of its own. If you feel capped by it then you just run another process on another machine and it will take part working on the same queue and sharing the load.

@BWStearns
Copy link
Contributor Author

Ok that's super cool. I added a PR adding the config description to the docs.

@kaplanelad
Copy link
Contributor

#412 - merged

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

3 participants