[db] add --no-ui param
parent
fc07cd27c4
commit
d07c9fd339
19
src/main.rs
19
src/main.rs
|
@ -49,6 +49,11 @@ fn main() -> Result<()> {
|
|||
.long("no-browser")
|
||||
.help("Do not open web browser with the UI."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("NO_UI")
|
||||
.long("no-ui")
|
||||
.help("Do not serve the web UI."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("NO_INITIAL_UPDATE")
|
||||
.long("no-initial-update")
|
||||
|
@ -99,8 +104,9 @@ fn main() -> Result<()> {
|
|||
};
|
||||
|
||||
// Start HTTP server
|
||||
let ui_enabled = !matches.is_present("NO_UI");
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
let app = App::new()
|
||||
.data(state.clone())
|
||||
.wrap(middleware::Logger::default().exclude("/api/jobs"))
|
||||
.service(routes::get_raw)
|
||||
|
@ -113,14 +119,19 @@ fn main() -> Result<()> {
|
|||
.service(routes::latest_files)
|
||||
.service(routes::get_file)
|
||||
.service(routes::get_jobs)
|
||||
.service(routes::get_info)
|
||||
.service(
|
||||
.service(routes::get_info);
|
||||
|
||||
if ui_enabled {
|
||||
app.service(
|
||||
actix_files::Files::new(
|
||||
"/",
|
||||
env::current_exe().unwrap().parent().unwrap().join("webui"),
|
||||
)
|
||||
.index_file("index.html"),
|
||||
)
|
||||
} else {
|
||||
app
|
||||
}
|
||||
})
|
||||
.bind(&bind)?
|
||||
.run();
|
||||
|
@ -130,7 +141,7 @@ fn main() -> Result<()> {
|
|||
actix::spawn(filesystem::rescan_vault(db_pool, vault_path, job_container));
|
||||
}
|
||||
|
||||
if !matches.is_present("NO_BROWSER") {
|
||||
if !matches.is_present("NO_BROWSER") && ui_enabled {
|
||||
let ui_result = webbrowser::open(&format!("http://localhost:{}", bind.port()));
|
||||
if ui_result.is_err() {
|
||||
warn!("Could not open UI in browser!");
|
||||
|
|
Loading…
Reference in New Issue