> For the complete documentation index, see [llms.txt](https://docs.rumi.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rumi.systems/rumi-core/guides/developing-applications/authoring-user-code/lifecycle.md).

# Lifecycle

This section covers how to implement lifecycle methods that control your microservice's initialization and shutdown behavior.

## Overview

Rumi microservices have a well-defined lifecycle from initialization through running to shutdown. You can hook into this lifecycle using annotations to perform setup, initialization, and cleanup tasks.

## Lifecycle Phases

1. **Construction** - Class instantiation
2. **Initialization** - `@AppInit` methods execute
3. **Running** - Message processing begins
4. **Shutdown** - `@AppShutdown` methods execute

## Topics

* [**Implementing Lifecycle Methods**](/rumi-core/guides/developing-applications/authoring-user-code/lifecycle/implementing-lifecycle-methods.md) - Use `@AppInit` and `@AppShutdown` annotations
* [**Initializing the Microservice**](/rumi-core/guides/developing-applications/authoring-user-code/lifecycle/initializing-the-microservice.md) - Handle first and initial messages for state initialization

## Related Topics

* [Microservice Lifecycle](/rumi-core/concepts/microservice-operation/lifecycle.md) - Conceptual overview of the full lifecycle
* [Cluster Initialization](/rumi-core/concepts/microservice-operation/cluster-initialization.md) - How microservices initialize in a cluster
