@@ -6,12 +6,14 @@ use ckb_async_runtime::{new_global_runtime, Handle};
6
6
use ckb_build_info:: Version ;
7
7
use ckb_launcher:: Launcher ;
8
8
use ckb_logger:: info;
9
+ use ckb_resource:: { Resource , TemplateContext } ;
9
10
10
11
use ckb_stop_handler:: { broadcast_exit_signals, wait_all_ckb_services_exit} ;
11
12
12
13
use ckb_types:: core:: cell:: setup_system_cell_cache;
13
14
14
15
pub fn run ( args : RunArgs , version : Version , async_handle : Handle ) -> Result < ( ) , ExitCode > {
16
+ check_default_db_options_exists ( & args) ?;
15
17
deadlock_detection ( ) ;
16
18
17
19
let rpc_threads_num = calc_rpc_threads_num ( & args) ;
@@ -79,3 +81,24 @@ fn calc_rpc_threads_num(args: &RunArgs) -> usize {
79
81
let default_num = usize:: max ( system_parallelism, 1 ) ;
80
82
args. config . rpc . threads . unwrap_or ( default_num)
81
83
}
84
+
85
+ fn check_default_db_options_exists ( args : & RunArgs ) -> Result < ( ) , ExitCode > {
86
+ // check is there a default.db-options file exist in args.config.root_dir, if not, create one.
87
+ let db_options_path = args. config . root_dir . join ( "default.db-options" ) ;
88
+
89
+ // Check if the default.db-options file exists, if not, create one.
90
+ if !db_options_path. exists ( ) {
91
+ warn ! (
92
+ "default.db-options file does not exist in {}, creating one." ,
93
+ args. config. root_dir
94
+ ) ;
95
+ // context_for_db_options is used to generate a default default.db-options file.
96
+ let context_for_db_options = TemplateContext :: new ( "" , vec ! [ ] ) ;
97
+
98
+ // Attempt to export the bundled DB options to the specified path.
99
+ Resource :: bundled_db_options ( )
100
+ . export ( & context_for_db_options, & args. config . root_dir )
101
+ . map_err ( |_| ExitCode :: Config ) ?;
102
+ }
103
+ Ok ( ( ) )
104
+ }
0 commit comments