mirror of
https://codeberg.org/spire/dispenser.git
synced 2026-06-03 10:04:07 +02:00
fix empty server detection and add option to manage existing instances
This commit is contained in:
parent
da2b13feb1
commit
86adb69a95
4 changed files with 13 additions and 1 deletions
|
|
@ -72,6 +72,8 @@ pub struct ServerConfig {
|
|||
#[serde(default = "server_default_tv_name")]
|
||||
pub tv_name: String,
|
||||
pub ssh_key: Option<String>,
|
||||
#[serde(default)]
|
||||
pub manage_existing: bool,
|
||||
}
|
||||
|
||||
fn server_default_image() -> String {
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -130,7 +130,15 @@ async fn run_loop(
|
|||
start_schedule: Schedule,
|
||||
stop_schedule: Schedule,
|
||||
) {
|
||||
let mut active_server: Option<Server> = None;
|
||||
let mut active_server = if config.server.manage_existing {
|
||||
cloud
|
||||
.list()
|
||||
.await
|
||||
.map(|servers| servers.into_iter().next())
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
loop {
|
||||
let next_start = start_schedule.upcoming(Utc).next().unwrap();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ impl Rcon {
|
|||
let player_lines = status
|
||||
.lines()
|
||||
.filter(|line| line.starts_with('#'))
|
||||
.filter(|line| !line.contains("# userid"))
|
||||
.filter(|line| !line.contains(" BOT "));
|
||||
Ok(player_lines.count())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue