Page MenuHomeDevCentral

main.rs
No OneTemporary

// -------------------------------------------------------------
// Alkane
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Project: Nasqueron
// License: BSD-2-Clause
// Description: Manage nginx and php-fpm Alkane PaaS
// -------------------------------------------------------------
use std::process::exit;
use clap::Parser;
use crate::actions::*;
use crate::command::{AlkaneCommand, ToStatusCode};
use crate::config::AlkaneConfig;
use crate::deploy::DeployError;
use crate::runner::RecipeStatus;
// -------------------------------------------------------------
// Modules
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mod actions;
mod command;
mod config;
mod db;
mod deploy;
mod runner;
mod server;
mod services;
// -------------------------------------------------------------
// Application entry point
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#[tokio::main]
async fn main() {
env_logger::init();
let command = AlkaneCommand::parse(); // Will exit if argument is missing or --help/--version provided.
let config = match AlkaneConfig::load() {
Ok(config) => config,
Err(error) => {
eprintln!("Can't load configuration: {:?}", error);
exit(4);
}
};
match command {
AlkaneCommand::Server => {
let result = serve(config).await;
exit(result.to_status_code())
}
AlkaneCommand::Update(args) => {
let result = update(&args.site_name, None, &config);
deploy_exit(result);
}
AlkaneCommand::Init(args) => {
let result = initialize(&args.site_name, None, &config);
deploy_exit(result);
}
AlkaneCommand::Deploy(args) => {
let result = deploy(&args.site_name, None, &config);
deploy_exit(result);
}
AlkaneCommand::IsPresent(args) => {
let is_present = is_present(&args.site_name, &config);
if !args.quiet {
if is_present {
let path = config.get_site_path(&args.site_name).unwrap();
println!("{}", path);
} else {
eprintln!("Site is absent.")
}
}
exit(is_present.to_status_code());
}
}
}
fn deploy_exit(result: Result<RecipeStatus, DeployError>) {
match result {
Ok(status) => exit(status.to_status_code()),
Err(error) => {
eprintln!("{}", error);
exit(16);
}
}
}

File Metadata

Mime Type
text/x-c
Expires
Sun, Oct 12, 05:05 (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3061167
Default Alt Text
main.rs (2 KB)

Event Timeline