@@ -3,20 +3,32 @@ use std::sync::Arc;
3
3
use anyhow:: Result ;
4
4
use graph_store_postgres:: connection_pool:: ConnectionPool ;
5
5
use 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
+ } ;
8
9
use graphman:: deployment:: DeploymentSelector ;
9
10
10
11
pub fn run (
11
12
primary_pool : ConnectionPool ,
12
13
notification_sender : Arc < NotificationSender > ,
13
14
deployment : DeploymentSelector ,
14
15
) -> Result < ( ) > {
15
- let active_deployment = load_active_deployment ( primary_pool. clone ( ) , & deployment) ? ;
16
+ let active_deployment = load_active_deployment ( primary_pool. clone ( ) , & deployment) ;
16
17
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
+ }
20
32
21
33
Ok ( ( ) )
22
34
}
0 commit comments