@@ -22,99 +22,6 @@ use zip::read::read_zipfile_from_stream;
22
22
use std:: os:: unix:: fs:: OpenOptionsExt ;
23
23
use std:: process:: Stdio ;
24
24
25
- /// Configuration for Temporalite.
26
- /// Will be removed eventually as its successor, Temporal CLI matures.
27
- /// We don't care for the duplication between this struct and [TemporalDevServerConfig] and prefer that over another
28
- /// abstraction since the existence of this struct is temporary.
29
- #[ derive( Debug , Clone , derive_builder:: Builder ) ]
30
- pub struct TemporaliteConfig {
31
- /// Required path to executable or download info.
32
- pub exe : EphemeralExe ,
33
- /// Namespace to use.
34
- #[ builder( default = "\" default\" .to_owned()" ) ]
35
- pub namespace : String ,
36
- /// IP to bind to.
37
- #[ builder( default = "\" 127.0.0.1\" .to_owned()" ) ]
38
- pub ip : String ,
39
- /// Port to use or obtains a free one if none given.
40
- #[ builder( default ) ]
41
- pub port : Option < u16 > ,
42
- /// Sqlite DB filename if persisting or non-persistent if none.
43
- #[ builder( default ) ]
44
- pub db_filename : Option < String > ,
45
- /// Whether to enable the UI.
46
- #[ builder( default ) ]
47
- pub ui : bool ,
48
- /// Log format and level
49
- #[ builder( default = "(\" pretty\" .to_owned(), \" warn\" .to_owned())" ) ]
50
- pub log : ( String , String ) ,
51
- /// Additional arguments to Temporalite.
52
- #[ builder( default ) ]
53
- pub extra_args : Vec < String > ,
54
- }
55
-
56
- impl TemporaliteConfig {
57
- /// Start a Temporalite server.
58
- pub async fn start_server ( & self ) -> anyhow:: Result < EphemeralServer > {
59
- self . start_server_with_output ( Stdio :: inherit ( ) , Stdio :: inherit ( ) )
60
- . await
61
- }
62
-
63
- /// Start a Temporalite server with configurable stdout destination.
64
- pub async fn start_server_with_output (
65
- & self ,
66
- output : Stdio ,
67
- err_output : Stdio ,
68
- ) -> anyhow:: Result < EphemeralServer > {
69
- // Get exe path
70
- let exe_path = self
71
- . exe
72
- . get_or_download ( "temporalite" , "temporalite" , None )
73
- . await ?;
74
-
75
- // Get free port if not already given
76
- let port = self . port . unwrap_or_else ( || get_free_port ( & self . ip ) ) ;
77
-
78
- // Build arg set
79
- let mut args = vec ! [
80
- "start" . to_owned( ) ,
81
- "--port" . to_owned( ) ,
82
- port. to_string( ) ,
83
- "--namespace" . to_owned( ) ,
84
- self . namespace. clone( ) ,
85
- "--ip" . to_owned( ) ,
86
- self . ip. clone( ) ,
87
- "--log-format" . to_owned( ) ,
88
- self . log. 0 . clone( ) ,
89
- "--log-level" . to_owned( ) ,
90
- self . log. 1 . clone( ) ,
91
- "--dynamic-config-value" . to_owned( ) ,
92
- "frontend.enableServerVersionCheck=false" . to_owned( ) ,
93
- ] ;
94
- if let Some ( db_filename) = & self . db_filename {
95
- args. push ( "--filename" . to_owned ( ) ) ;
96
- args. push ( db_filename. clone ( ) ) ;
97
- } else {
98
- args. push ( "--ephemeral" . to_owned ( ) ) ;
99
- }
100
- if !self . ui {
101
- args. push ( "--headless" . to_owned ( ) ) ;
102
- }
103
- args. extend ( self . extra_args . clone ( ) ) ;
104
-
105
- // Start
106
- EphemeralServer :: start ( EphemeralServerConfig {
107
- exe_path,
108
- port,
109
- args,
110
- has_test_service : false ,
111
- output,
112
- err_output,
113
- } )
114
- . await
115
- }
116
- }
117
-
118
25
/// Configuration for Temporal CLI dev server.
119
26
#[ derive( Debug , Clone , derive_builder:: Builder ) ]
120
27
pub struct TemporalDevServerConfig {
@@ -326,6 +233,12 @@ impl EphemeralServer {
326
233
Ok ( ( ) )
327
234
}
328
235
}
236
+
237
+ /// Get the process ID of the child. This will be None if the process is
238
+ /// considered to be complete.
239
+ pub fn child_process_id ( & self ) -> Option < u32 > {
240
+ self . child . id ( )
241
+ }
329
242
}
330
243
331
244
/// Where to find an executable. Can be a path or download.
0 commit comments