embed migrations, fix start, add stop

This commit is contained in:
2026-06-09 17:09:07 +02:00
parent 5136e0bdc3
commit 408530db00
16 changed files with 212 additions and 26 deletions

View File

@ -1,11 +1,14 @@
use bollard::Docker;
use chrono::Utc;
use clap::Arg;
use clap::{Command, ArgMatches};
use crate::DbPool;
use crate::{ DbPool, schema };
use crate::dockermgr;
use diesel::prelude::*;
pub fn create_subcommand() -> Command {
Command::new("start")
.about("manually start a server (and set last login datetime to now)")
@ -13,8 +16,11 @@ pub fn create_subcommand() -> Command {
}
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: Docker) -> Result<(), String> {
use schema::servers::dsl::*;
let server_name = arguments.get_one::<String>("NAME").unwrap();
dockermgr::start_server(&docker, pool, server_name).await?;
diesel::update(servers).filter(name.eq(server_name)).set(last_login.eq(Utc::now().naive_utc())).execute(&mut pool.get().unwrap()).map_err(|e| format!("Failed to set the last login date: {}", e))?;
Ok(())
}