Skip to content

refactor and unify task startup and shutdown across binaries #627

@noot

Description

@noot

Description

currently, each binary uses a different method for starting up its different components; some do this all in main.rs and others in a command, and the shutdown and task handle stopping is handled differently. the binaries should all have a similar structure for task startup and shutdown.

Proposed Solution

startup:

  • every binary should have one entrypoint (eg. Worker, Validator) which is the only thing exposed from the library part of the crate. main.rs should then spawn worker.run() for example to start the service. the run() function will consume self and spawn all the different components necessary, run them in a select loop, and handle cancellation signals

shutdown:

  • run() should only return upon a critical error which the service cannot recover from. otherwise, errors should be logged or handled some other way.
  • if run() returns, or if a cancellation signal is received, shutdown should be initiated by signaling all spawned tasks and waiting for them to complete in some amount of time (30s). if they don't finish by this time, they can be aborted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions