Fix local worker not connecting
This commit is contained in:
parent
3af90a8edf
commit
76ab00c47a
2 changed files with 15 additions and 14 deletions
|
|
@ -118,11 +118,10 @@ pub struct ServerConfig {
|
||||||
pub repo_fetch_refspecs: Vec<String>,
|
pub repo_fetch_refspecs: Vec<String>,
|
||||||
pub repo_fetch_url: Option<String>,
|
pub repo_fetch_url: Option<String>,
|
||||||
pub web_address: SocketAddr,
|
pub web_address: SocketAddr,
|
||||||
/// Always ends without a `/`.
|
/// Always starts with a `/` and ends without a `/`, preferring the latter.
|
||||||
///
|
///
|
||||||
/// This means that you can prefix the base onto an absolute path and get
|
/// This means that you can prefix the base onto an absolute path and get
|
||||||
/// another absolute path. You could also use an url here if you have a
|
/// another absolute path.
|
||||||
/// weird reason to do so.
|
|
||||||
pub web_base: String,
|
pub web_base: String,
|
||||||
pub worker_token: String,
|
pub worker_token: String,
|
||||||
pub worker_timeout: Duration,
|
pub worker_timeout: Duration,
|
||||||
|
|
@ -145,18 +144,23 @@ impl ServerConfig {
|
||||||
"unnamed repo".to_string()
|
"unnamed repo".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn web_base(mut base: String) -> String {
|
||||||
|
if !base.starts_with('/') {
|
||||||
|
base.insert(0, '/');
|
||||||
|
}
|
||||||
|
if base.ends_with('/') {
|
||||||
|
base.pop();
|
||||||
|
}
|
||||||
|
base
|
||||||
|
}
|
||||||
|
|
||||||
fn from_raw_server(raw: RawServer, args: &Args) -> Self {
|
fn from_raw_server(raw: RawServer, args: &Args) -> Self {
|
||||||
let repo_name = match raw.repo.name {
|
let repo_name = match raw.repo.name {
|
||||||
Some(name) => name,
|
Some(name) => name,
|
||||||
None => Self::repo_name(args),
|
None => Self::repo_name(args),
|
||||||
};
|
};
|
||||||
|
|
||||||
let web_base = raw
|
let web_base = Self::web_base(raw.web.base);
|
||||||
.web
|
|
||||||
.base
|
|
||||||
.strip_suffix('/')
|
|
||||||
.unwrap_or(&raw.web.base)
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let worker_token = match raw.worker.token {
|
let worker_token = match raw.worker.token {
|
||||||
Some(token) => token,
|
Some(token) => token,
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,7 @@ fn local_url(config: &ServerConfig) -> String {
|
||||||
};
|
};
|
||||||
let port = config.web_address.port();
|
let port = config.web_address.port();
|
||||||
let base = &config.web_base;
|
let base = &config.web_base;
|
||||||
if base.starts_with('/') {
|
|
||||||
format!("http://{host}:{port}{base}")
|
format!("http://{host}:{port}{base}")
|
||||||
} else {
|
|
||||||
format!("http://{host}:{port}/{base}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn open_in_browser(config: &ServerConfig) {
|
async fn open_in_browser(config: &ServerConfig) {
|
||||||
|
|
@ -137,6 +133,7 @@ async fn launch_local_workers(config: &'static Config, amount: u8) {
|
||||||
let worker_config = Box::leak(Box::new(worker_config));
|
let worker_config = Box::leak(Box::new(worker_config));
|
||||||
|
|
||||||
info!("Starting local worker {}", worker_config.name);
|
info!("Starting local worker {}", worker_config.name);
|
||||||
|
trace!("Worker config: {worker_config:#?}");
|
||||||
let worker = Worker::new(worker_config);
|
let worker = Worker::new(worker_config);
|
||||||
tokio::spawn(async move { worker.run().await });
|
tokio::spawn(async move { worker.run().await });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue