<a id="reference-juju-events"></a>

# Juju events

The charm follows a holistic (reconcile) pattern: nearly every lifecycle event
is routed to a single idempotent handler that ensures osquery is installed,
renders the flagfile from the current configuration, and (re)starts the daemon.

The following Juju events are observed:

1. [install](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-install):

   installs the `c-osquery` snap from the configured `snap-channel` and
   applies the initial configuration.
2. [upgrade-charm](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-upgrade-charm):

   re-runs the reconcile after a charm upgrade.
3. [start](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-start):

   reconciles when the unit starts.
4. [config-changed](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-config-changed):

   rebuilds the flagfile and secret files whenever an option changes, then
   restarts the daemon.
5. [secret-changed](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-secret-changed):

   re-reads a Juju secret (for example the enrollment secret or TLS client
   key) when its content is updated, and re-applies the configuration.
6. [update-status](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-update-status):

   periodically reconciles so the unit self-heals and reports accurate status.
7. [stop](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook-stop):

   removes the `c-osquery` snap (which stops the daemon) and purges its data
   during tear-down.

#### SEE ALSO
See more in the Juju docs: [Hook](https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#hook)
