Procyon|Docs
Runtime

Run Applications

Follow the application runtime from entrypoint to shutdown.

The runtime is the part of Procyon that turns your registered constructors, configuration files, command-line arguments, and lifecycle components into a running application.

Most applications only need a small main() function, but the runtime gives you clear extension points when the application grows: environment customizers, context initializers, command-line runners, lifecycle components, and server components.

main.go
func main() {
    if err := procyon.Run(); err != nil {
        os.Exit(1)
    }
}

Startup sequence

  1. Parse --name=value command-line arguments.
  2. Create the environment and add argument/environment property sources.
  3. Run environment customizers, including configuration file loading.
  4. Create the runtime context.
  5. Run context initializers.
  6. Refresh the context: load component definitions, customize the container, register processors, initialize singletons, and start lifecycle components.
  7. Run command-line runners.
  8. Keep the process alive when a server component exists.
  9. Close the context and dispose singletons on shutdown.

This order matters. Configuration is available before components are created, container customizers run before singletons are initialized, and lifecycle components start only after the component graph is ready.

Choosing an extension point

Use the earliest hook that matches the job:

  • EnvironmentCustomizer for adding property sources or selecting profiles.
  • ContextInitializer for context-level setup before refresh.
  • ContainerCustomizer for registering extra container state before singleton initialization.
  • CommandLineRunner for CLI work after the app is ready.
  • Lifecycle for long-running resources that need start and stop behavior.
  • Server for applications that should continue serving until a shutdown signal arrives.