@@ -30,7 +30,7 @@ use std::convert::Infallible;
30
30
use std:: sync:: Arc ;
31
31
use std:: time:: Duration ;
32
32
use futures_util:: TryFutureExt ;
33
- use tracing:: { error, warn } ;
33
+ use tracing:: error;
34
34
use warp:: Filter ;
35
35
use crate :: tls:: load_ssl_server_config;
36
36
@@ -104,18 +104,10 @@ pub async fn reload_server(
104
104
pub async fn run_server ( ) -> anyhow:: Result < ( ) > {
105
105
let config = Config :: load ( ) ?;
106
106
tracing:: debug!( "config load:{:?}" , & config) ;
107
+ run_server_with_config ( config) . await
108
+ }
107
109
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 < ( ) > {
119
111
let cache = FileCache :: new ( & config) ;
120
112
let domain_storage = Arc :: new ( DomainStorage :: init ( & config. file_dir , cache) ?) ;
121
113
let server = Server :: new ( config. clone ( ) , domain_storage. clone ( ) ) ;
@@ -164,8 +156,6 @@ pub async fn run_server() -> anyhow::Result<()> {
164
156
panic!( "admin server error: {error}" )
165
157
} )
166
158
) ;
167
-
168
-
169
159
} else {
170
160
tracing:: info!( "admin server disabled" ) ;
171
161
@@ -192,9 +182,8 @@ pub async fn run_server() -> anyhow::Result<()> {
192
182
} ) ,
193
183
) ;
194
184
}
195
-
196
185
Ok ( ( ) )
197
186
}
198
187
199
- // #[cfg(test)]
188
+ #[ cfg( test) ]
200
189
pub const LOCAL_HOST : & str = "local.fornetcode.com" ;
0 commit comments