Explicitely start async executor
This commit is contained in:
parent
1c84cde158
commit
289827d6a3
2 changed files with 21 additions and 17 deletions
10
src/main.rs
10
src/main.rs
|
@ -217,8 +217,9 @@ fn main() -> Result<()> {
|
|||
.unwrap_or_else(|| "5050".to_owned())
|
||||
.parse()
|
||||
.with_context(|| "Invalid port number")?;
|
||||
|
||||
service::server::run(
|
||||
let db_server = db.clone();
|
||||
std::thread::spawn(move || {
|
||||
let _ = service::server::run(
|
||||
port,
|
||||
Some(auth_secret.as_slice()),
|
||||
api_url,
|
||||
|
@ -226,9 +227,10 @@ fn main() -> Result<()> {
|
|||
web_dir_path,
|
||||
swagger_url,
|
||||
swagger_dir_path,
|
||||
db.clone(),
|
||||
db_server,
|
||||
command_sender,
|
||||
)?;
|
||||
);
|
||||
});
|
||||
|
||||
// Start DDNS updates
|
||||
let db_ddns = db.clone();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use actix_rt::System;
|
||||
use actix_web::{App, HttpServer};
|
||||
use anyhow::*;
|
||||
use std::path::PathBuf;
|
||||
|
@ -6,8 +7,7 @@ use std::sync::Arc;
|
|||
use crate::db::DB;
|
||||
use crate::index::CommandSender;
|
||||
|
||||
#[actix_rt::main]
|
||||
pub async fn run(
|
||||
pub fn run(
|
||||
port: u16,
|
||||
auth_secret: Option<&[u8]>,
|
||||
api_url: String,
|
||||
|
@ -18,7 +18,9 @@ pub async fn run(
|
|||
db: DB,
|
||||
command_sender: Arc<CommandSender>,
|
||||
) -> Result<()> {
|
||||
HttpServer::new(move || {
|
||||
let mut sys = System::new("polaris_service_executor");
|
||||
|
||||
let server = HttpServer::new(move || {
|
||||
App::new().configure(|cfg| {
|
||||
super::configure_app(
|
||||
cfg,
|
||||
|
@ -30,8 +32,8 @@ pub async fn run(
|
|||
)
|
||||
})
|
||||
})
|
||||
.bind(format!("127.0.0.1:{}", port))?
|
||||
.bind(format!("0.0.0.0:{}", port))?
|
||||
.run();
|
||||
|
||||
Ok(())
|
||||
sys.block_on(server).map_err(Error::new)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue