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.
func main() {
if err := procyon.Run(); err != nil {
os.Exit(1)
}
}Startup sequence
- Parse
--name=valuecommand-line arguments. - Create the environment and add argument/environment property sources.
- Run environment customizers, including configuration file loading.
- Create the runtime context.
- Run context initializers.
- Refresh the context: load component definitions, customize the container, register processors, initialize singletons, and start lifecycle components.
- Run command-line runners.
- Keep the process alive when a server component exists.
- 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:
EnvironmentCustomizerfor adding property sources or selecting profiles.ContextInitializerfor context-level setup before refresh.ContainerCustomizerfor registering extra container state before singleton initialization.CommandLineRunnerfor CLI work after the app is ready.Lifecyclefor long-running resources that need start and stop behavior.Serverfor applications that should continue serving until a shutdown signal arrives.
Application
Follow what happens when `procyon.Run()` starts the app.
Context
Use the runtime context to access the environment, container, and resources.
Environment
Read profiles, property sources, and resolved configuration at runtime.
Command-line runners
Run CLI workloads after the application context is ready.
Servers
Provide a server component when the application should keep serving requests.
Lifecycle
Start and stop long-running resources with the context lifecycle.
