Comments (7)
I have a strong preference for a batteries-included type interface with mosquito, even though it's not all there yet.
I like the idea of a blocking stop command, but I'd probably make it optional as with start. stop(wait: true)
would wait for the shutdown before exiting and stop()
return immediately.
Regardless, the runner's notion of state needs to be more robust so it can handle at least: running, shutting down, stopped.
from mosquito.
@jgaskins 51904a0 is merged and includes improvements to the Runner interface. You can now call Mosquito::Runner.stop(wait: true)
and it will not return until it's finished working.
You can then modify your worker.cr with a signal handler which will respond to SIGINT or whatever is right for your deployment.
See the Runner docs for details.
from mosquito.
Yes, you're right Runner#stop will do what you want.
The implementation of this isn't quite universal -- it depends on how you're booting up your worker. The demo script has this code in it:
Signal::INT.trap do
Mosquito::Runner.stop
end
Mosquito::Runner.start(spin: false)
You could certainly trap Signal::QUIT and TERM instead or in addition. However, Mosquito::Runner.stop is not captive. I don't think that should be a problem -- though it may mean you need to implement some sort of spin lock on your own to wait for shutdown.
from mosquito.
it may mean you need to implement some sort of spin lock on your own to wait for shutdown.
This is one of the reasons I posted this issue, actually. If I start the runner with runner.start(spin: false)
and stop it with runner.stop
, how do I know when that runner is done? I don't see a way to inspect its running state.
from mosquito.
Interesting, I see what you mean.
The start(spin: false)
interface doesn't really please me, but I don't know what I should replace it with... and I think the lack of pattern to mimic leaves me without good vision for what stop should look like. What would you want to do here? The demo script I linked above spins around a check on keep_running
, but that is also not well named anymore because the runner has more granularity than simply running and not-running.
Do you have a suggestion of an interface that would accomplish what you're thinking? Can you share what you are currently doing to work-around the lack of functionality?
from mosquito.
I've been trying to come up with something for this for the past couple days. I feel like the default functionality with start
is a solid interface (start
blocks until it's finished), and maybe both start
and stop
could block until the runner exits so that regardless of how you structure things it'll just work, but I don't know if the juice is worth the squeeze on that.
I agree that spin: false
isn't ideal, though. Since blocking operations in Crystal can be moved to the background with spawn
, it may not actually be necessary to solve in Mosquito.
from mosquito.
I have a strong preference for a batteries-included type interface with mosquito
💯 For folks who came to Crystal from languages where the convention is to load code at runtime using a CLI provided by a framework, having to write our own entrypoint into the background-job runner which loads all of our jobs is new, so reducing that cognitive load as much as is feasible goes a long way.
from mosquito.
Related Issues (20)
- Provide a way to detect and clean up jobs which were started but never finished HOT 1
- Redis RPOPLPUSH command is deprecated since Redis 6.2
- Provide an easy way to cancel a job without it being rescheduled
- Support error handlers HOT 3
- Update runner to use time::span instead of bare seconds, and monotonic for the idle wait
- Leaky Bucket Queue?
- Array support for params (or better error message...) HOT 5
- mosquito is completely broken after 1.0.1 HOT 5
- High CPU usage HOT 9
- Make executor count configurable HOT 1
- Ability to specify a redis connection pool from an application, instead of making mosquito handle it all
- Add a before/after enqueue set of hooks
- Add hook for job-interrupted, and improve scheduling logic to requeue a job if it needs to be terminated
- unknown command `lmove` HOT 6
- Add ability to configure global Redis namespace prefix HOT 1
- Unexpected argument when using `-Dno_number_autocast` HOT 1
- Crash - ERR too many keys to fetch, please use SCAN
- Should Periodic Jobs include a way to manually enqueue them?
- `Mosquito::VERSION` in `2.0.0` release
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mosquito.