@@ -30,7 +30,7 @@ use std::convert::Infallible;
3030use std:: sync:: Arc ;
3131use std:: time:: Duration ;
3232use futures_util:: TryFutureExt ;
33- use tracing:: { error, warn } ;
33+ use tracing:: error;
3434use warp:: Filter ;
3535use crate :: tls:: load_ssl_server_config;
3636
@@ -104,18 +104,10 @@ pub async fn reload_server(
104104pub async fn run_server ( ) -> anyhow:: Result < ( ) > {
105105 let config = Config :: load ( ) ?;
106106 tracing:: debug!( "config load:{:?}" , & config) ;
107+ run_server_with_config ( config) . await
108+ }
107109
108- if config. http . is_none ( ) && config. https . is_none ( ) {
109- panic ! ( "should set http or https server config" ) ;
110- }
111- if let Some ( http_config) = & config. https {
112- if http_config. acme . is_some ( ) && http_config. ssl . is_some ( ) {
113- panic ! ( "spa-server don't support ssl and acme config in the meantime" ) ;
114- }
115- if http_config. acme . is_some ( ) && config. http . as_ref ( ) . filter ( |v|v. port != 80 ) . is_none ( ) {
116- warn ! ( "acme needs http port:80 to signed https certificate" ) ;
117- }
118- }
110+ pub async fn run_server_with_config ( config : Config ) -> anyhow:: Result < ( ) > {
119111 let cache = FileCache :: new ( & config) ;
120112 let domain_storage = Arc :: new ( DomainStorage :: init ( & config. file_dir , cache) ?) ;
121113 let server = Server :: new ( config. clone ( ) , domain_storage. clone ( ) ) ;
@@ -164,8 +156,6 @@ pub async fn run_server() -> anyhow::Result<()> {
164156 panic!( "admin server error: {error}" )
165157 } )
166158 ) ;
167-
168-
169159 } else {
170160 tracing:: info!( "admin server disabled" ) ;
171161
@@ -192,9 +182,8 @@ pub async fn run_server() -> anyhow::Result<()> {
192182 } ) ,
193183 ) ;
194184 }
195-
196185 Ok ( ( ) )
197186}
198187
199- // #[cfg(test)]
188+ #[ cfg( test) ]
200189pub const LOCAL_HOST : & str = "local.fornetcode.com" ;
0 commit comments