@@ -3,20 +3,32 @@ use std::sync::Arc;
33use anyhow:: Result ;
44use graph_store_postgres:: connection_pool:: ConnectionPool ;
55use graph_store_postgres:: NotificationSender ;
6- use graphman:: commands:: deployment:: pause:: load_active_deployment;
7- use graphman:: commands:: deployment:: pause:: pause_active_deployment;
6+ use graphman:: commands:: deployment:: pause:: {
7+ load_active_deployment, pause_active_deployment, PauseDeploymentError ,
8+ } ;
89use graphman:: deployment:: DeploymentSelector ;
910
1011pub fn run (
1112 primary_pool : ConnectionPool ,
1213 notification_sender : Arc < NotificationSender > ,
1314 deployment : DeploymentSelector ,
1415) -> Result < ( ) > {
15- let active_deployment = load_active_deployment ( primary_pool. clone ( ) , & deployment) ? ;
16+ let active_deployment = load_active_deployment ( primary_pool. clone ( ) , & deployment) ;
1617
17- println ! ( "Pausing deployment {} ..." , active_deployment. locator( ) ) ;
18-
19- pause_active_deployment ( primary_pool, notification_sender, active_deployment) ?;
18+ match active_deployment {
19+ Ok ( active_deployment) => {
20+ println ! ( "Pausing deployment {} ..." , active_deployment. locator( ) ) ;
21+ pause_active_deployment ( primary_pool, notification_sender, active_deployment) ?;
22+ }
23+ Err ( PauseDeploymentError :: AlreadyPaused ( locator) ) => {
24+ println ! ( "Deployment {} is already paused" , locator) ;
25+ return Ok ( ( ) ) ;
26+ }
27+ Err ( PauseDeploymentError :: Common ( e) ) => {
28+ println ! ( "Failed to load active deployment: {}" , e) ;
29+ return Err ( e. into ( ) ) ;
30+ }
31+ }
2032
2133 Ok ( ( ) )
2234}
0 commit comments