embed migrations, fix start, add stop
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use chrono::Utc;
|
||||
use clap::{ArgMatches, Command, arg};
|
||||
use crate::cli::env_settings;
|
||||
use crate::status::ServerStatus;
|
||||
@ -9,7 +10,7 @@ use crate::{DbPool, models}; use crate::schema;
|
||||
use tokio::{fs::{File, create_dir}, io::AsyncWriteExt};
|
||||
|
||||
use std::path::Path;
|
||||
use std::time::SystemTime;
|
||||
|
||||
|
||||
pub fn create_subcommand() -> Command {
|
||||
let mut arguments = vec![
|
||||
@ -56,15 +57,13 @@ pub async fn subcommand(arg: &ArgMatches, pool: DbPool) -> Result<(), String>{
|
||||
std::fs::remove_dir_all(path.to_string() + "tmp").map_err(|e| format!("failed to remove the tmp dir, reason : {}", e))?;
|
||||
}
|
||||
|
||||
let _new_server = models::CreateServer {
|
||||
let new_server = models::CreateServer {
|
||||
name: server_name,
|
||||
last_login: Some(SystemTime::now()),
|
||||
container_id: None,
|
||||
last_login: Some(Utc::now().naive_utc()),
|
||||
status: ServerStatus::Stopped,
|
||||
redirect_ip: None
|
||||
};
|
||||
|
||||
// diesel::insert_into(schema::servers::dsl::servers).values(&new_server).execute(conn).map_err(|e| format!("Failed to insert in db, error : {:?}", e))?;
|
||||
// TODO: fix weird error
|
||||
diesel::insert_into(servers).values(&new_server).execute(conn).map_err(|e| format!("Failed to insert in db, error : {:?}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user