Init
This commit is contained in:
14
docker-compose.pgsql.yml
Normal file
14
docker-compose.pgsql.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
volumes:
|
||||
pgsql_data:
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:18-alpine
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: postgres
|
||||
volumes:
|
||||
- pgsql_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
@@ -49,6 +49,18 @@ impl App {
|
||||
pub async fn run(&self) {
|
||||
println!("Application démarrée. Appuyez sur Ctrl+C pour arrêter.");
|
||||
|
||||
// On définit les signaux d'arrêt selon la plateforme
|
||||
#[cfg(unix)]
|
||||
let terminate = async {
|
||||
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
|
||||
.expect("failed to install signal handler")
|
||||
.recv()
|
||||
.await;
|
||||
};
|
||||
|
||||
#[cfg(not(unix))]
|
||||
let terminate = std::future::pending::<()>();
|
||||
|
||||
// Le select arbitre la course
|
||||
tokio::select! {
|
||||
// Branche 1 : Le serveur tourne. S'il crash ou finit (peu probable), on sort.
|
||||
@@ -65,6 +77,10 @@ impl App {
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
println!("Signal d'arrêt reçu !");
|
||||
}
|
||||
|
||||
_ = terminate => {
|
||||
println!("Signal SIGTERM reçu (Docker stop) !");
|
||||
}
|
||||
}
|
||||
|
||||
println!("Nettoyage et fermeture de l'application.");
|
||||
|
||||
Reference in New Issue
Block a user