14
14
15
15
use std:: env;
16
16
use std:: fmt:: Write ;
17
- use std:: path:: Path ;
17
+ use std:: path:: { Path , PathBuf } ;
18
18
use std:: sync:: Arc ;
19
19
use std:: time:: { Duration , Instant } ;
20
20
@@ -27,7 +27,7 @@ use risedev::{
27
27
generate_risedev_env, preflight_check, AwsS3Config , CompactorService , ComputeNodeService ,
28
28
ConfigExpander , ConfigureTmuxTask , EnsureStopService , ExecuteContext , FrontendService ,
29
29
GrafanaService , KafkaService , MetaNodeService , MinioService , OpendalConfig , PrometheusService ,
30
- PubsubService , RedisService , ServiceConfig , Task , TempoService , ZooKeeperService ,
30
+ PubsubService , RedisService , ServiceConfig , SqliteConfig , Task , TempoService , ZooKeeperService ,
31
31
RISEDEV_SESSION_NAME ,
32
32
} ;
33
33
use tempfile:: tempdir;
@@ -101,6 +101,7 @@ fn task_main(
101
101
let listen_info = match service {
102
102
ServiceConfig :: Minio ( c) => Some ( ( c. port , c. id . clone ( ) ) ) ,
103
103
ServiceConfig :: Etcd ( c) => Some ( ( c. port , c. id . clone ( ) ) ) ,
104
+ ServiceConfig :: Sqlite ( _) => None ,
104
105
ServiceConfig :: Prometheus ( c) => Some ( ( c. port , c. id . clone ( ) ) ) ,
105
106
ServiceConfig :: ComputeNode ( c) => Some ( ( c. port , c. id . clone ( ) ) ) ,
106
107
ServiceConfig :: MetaNode ( c) => Some ( ( c. port , c. id . clone ( ) ) ) ,
@@ -158,6 +159,34 @@ fn task_main(
158
159
risedev:: ConfigureGrpcNodeTask :: new ( c. address . clone ( ) , c. port , false ) ?;
159
160
task. execute ( & mut ctx) ?;
160
161
}
162
+ ServiceConfig :: Sqlite ( c) => {
163
+ let mut ctx =
164
+ ExecuteContext :: new ( & mut logger, manager. new_progress ( ) , status_dir. clone ( ) ) ;
165
+
166
+ struct SqliteService ( SqliteConfig ) ;
167
+ impl Task for SqliteService {
168
+ fn execute (
169
+ & mut self ,
170
+ _ctx : & mut ExecuteContext < impl std:: io:: Write > ,
171
+ ) -> anyhow:: Result < ( ) > {
172
+ Ok ( ( ) )
173
+ }
174
+
175
+ fn id ( & self ) -> String {
176
+ self . 0 . id . clone ( )
177
+ }
178
+ }
179
+
180
+ let prefix_data = env:: var ( "PREFIX_DATA" ) ?;
181
+ let file_dir = PathBuf :: from ( & prefix_data) . join ( & c. id ) ;
182
+ std:: fs:: create_dir_all ( & file_dir) ?;
183
+ let file_path = file_dir. join ( & c. file ) ;
184
+
185
+ ctx. service ( & SqliteService ( c. clone ( ) ) ) ;
186
+ ctx. complete_spin ( ) ;
187
+ ctx. pb
188
+ . set_message ( format ! ( "using local sqlite: {:?}" , file_path) ) ;
189
+ }
161
190
ServiceConfig :: Prometheus ( c) => {
162
191
let mut ctx =
163
192
ExecuteContext :: new ( & mut logger, manager. new_progress ( ) , status_dir. clone ( ) ) ;
0 commit comments