@@ -71,13 +71,19 @@ pub async fn serve_web(ctx: CommandContext, mut args: ServeWebArgs) -> Result<i3
71
71
72
72
let platform: crate :: update_service:: Platform = PreReqChecker :: new ( ) . verify ( ) . await ?;
73
73
if !args. without_connection_token {
74
- // Ensure there's a defined connection token, since if multiple server versions
75
- // are excuted, they will need to have a single shared token.
76
- let token_path = ctx. paths . root ( ) . join ( "serve-web-token" ) ;
77
- let token = mint_connection_token ( & token_path, args. connection_token . clone ( ) )
78
- . map_err ( CodeError :: CouldNotCreateConnectionTokenFile ) ?;
79
- args. connection_token = Some ( token) ;
80
- args. connection_token_file = Some ( token_path. to_string_lossy ( ) . to_string ( ) ) ;
74
+ if let Some ( p) = args. connection_token_file . as_deref ( ) {
75
+ let token = fs:: read_to_string ( PathBuf :: from ( p) )
76
+ . map_err ( CodeError :: CouldNotReadConnectionTokenFile ) ?;
77
+ args. connection_token = Some ( token. trim ( ) . to_string ( ) ) ;
78
+ } else {
79
+ // Ensure there's a defined connection token, since if multiple server versions
80
+ // are executed, they will need to have a single shared token.
81
+ let token_path = ctx. paths . root ( ) . join ( "serve-web-token" ) ;
82
+ let token = mint_connection_token ( & token_path, args. connection_token . clone ( ) )
83
+ . map_err ( CodeError :: CouldNotCreateConnectionTokenFile ) ?;
84
+ args. connection_token = Some ( token) ;
85
+ args. connection_token_file = Some ( token_path. to_string_lossy ( ) . to_string ( ) ) ;
86
+ }
81
87
}
82
88
83
89
let cm = ConnectionManager :: new ( & ctx, platform, args. clone ( ) ) ;
0 commit comments