1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Run subcommand starts the server with a configuration based on
//! parameters, environment variables, or default config values.
//!
//! ## Run Subcommand
//!
//! Starts the server and loads all necessary configurations before
//! accepting incoming requests. This command initializes the application
//! runtime, sets up the API routes, and begins listening on the configured
//! host and port. It is used in both development and production
//! environments to bring the service online.
//!
//! ### Usage
//!
//! ```text
//! <binary> run
//! ```
use crate::;
use ServiceConfig;
use Args;
use Colorize;
use ComposeCommand;
use Error;
/// Command-line arguments for starting the application.
///
/// This struct is derived from `clap::Args` and represents
/// the basic CLI parameters accepted by the `run` command.
pub
/// Processes a server shutdown command using the provided settings.
///
/// This function triggers the server bootstrap routine and, if a Docker
/// Compose is detected in the configuration, starts the docker compose.
/// At the server shutdown, attempts to gracefully stop its containers.
/// After the shutdown process, a success or failure message is printed.
///
/// # Parameters
/// - `settings`: Reference to the server configuration.
/// - `fnconfig`: Optional callback used to customize the Actix-Web
/// `ServiceConfig` during initialization.
///
/// # Behavior
/// - Bootstrap the server using the settings configuration;
/// - At the server shutdown process:
/// - Stops Docker Compose services when available.
/// - Prints a confirmation message when the server is shut down.
/// - If an error occurs:
/// - Prints a failure message.
pub async
/// Attempts to process a shutdown command for the server.
///
/// This function initializes the server bootstrap using the provided
/// `settings` and optional service configuration function. If a Docker
/// Compose environment is detected, it gracefully stops all running
/// containers associated with the server.
///
/// Any errors encountered while stopping Docker Compose services are
/// logged as warnings and do not prevent the shutdown process from
/// completing.
///
/// # Parameters
/// - `settings`: Reference to the application [`Settings`] used during bootstrap.
/// - `fnconfig`: Optional function used to customize the [`ServiceConfig`].
///
/// # Returns
/// - `Ok(())` if the shutdown process completes successfully.
/// - An [`std::io::Error`] if the server bootstrap fails.
async
/// A type alias for a `Result` with the `RunError` error type.
pub type Result<T, E = RunError> = Result;
/// Represents an error that occurred during the server bootstrap process.
///
/// This enum groups all errors that may occur when starting the server
/// into a single type, making error handling more consistent across
/// the application. Each variant represents a specific failure scenario
/// and provides a human-readable error message.
///
/// # Variants
/// - `RunError`: An error that occurred during the server bootstrap process.
/// - `Custom`: A custom error message that can be used to wrap other types of errors.
pub