move ffpc to branch for now

This commit is contained in:
jb-alvarado 2022-05-23 16:29:55 +02:00
parent 11db9f5626
commit 29eb0da70b
4 changed files with 35 additions and 849 deletions

786
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -9,14 +9,11 @@ edition = "2021"
default-run = "ffplayout"
[dependencies]
anyhow = "1.0"
chrono = { git = "https://github.com/sbrocket/chrono", branch = "parse-error-kind-public" }
clap = { version = "3.1", features = ["derive"] }
crossbeam-channel = "0.5"
ffprobe = "0.3"
file-rotate = { git = "https://github.com/Ploppz/file-rotate.git", branch = "timestamp-parse-fix" }
horust = "0.1"
itertools = "0.10"
jsonrpc-http-server = "18.0"
lettre = "0.10.0-rc.6"
log = "0.4"

View File

@ -1,14 +0,0 @@
[Unit]
Description=ffplayout process control
After=network.target remote-fs.target
[Service]
ExecStart= /usr/bin/ffpc
ExecReload=/bin/kill -1 $MAINPID
Restart=always
RestartSec=1
User=www-data
Group=www-data
[Install]
WantedBy=multi-user.target

View File

@ -1,81 +0,0 @@
use std::path::PathBuf;
use anyhow::{Context, Result};
use clap::Parser;
use itertools::Itertools;
use horust::horust::ExitStatus;
use horust::horust::HorustConfig;
use horust::Horust;
#[derive(Parser, Debug)]
#[clap(version,
name = "ffpc",
version = "0.1.0",
about = "ffplayout process control",
long_about = None)]
pub struct Args {
#[clap(
short,
long,
help = "File path to ffpc.toml",
default_value = "/etc/ffplayout/ffpc.toml"
)]
config_path: PathBuf,
#[clap(
short,
long = "services-path",
help = "Play folder content",
default_value = "/etc/ffplayout/services"
)]
services_paths: Vec<PathBuf>,
}
fn main() -> Result<()> {
let opts = Args::parse();
let horust_cfg = HorustConfig {
unsuccessful_exit_finished_failed: true,
};
let config =
HorustConfig::load_and_merge(&horust_cfg, &opts.config_path).with_context(|| {
format!(
"Failed loading configuration: {}",
&opts.config_path.display()
)
})?;
println!(
"Loading services from {}",
display_directories(&opts.services_paths)
);
let mut horust = {
Horust::from_services_dirs(&opts.services_paths).with_context(|| {
format!(
"Failed loading services from {}",
display_directories(&opts.services_paths)
)
})?
};
if let ExitStatus::SomeServiceFailed = horust.run() {
if config.unsuccessful_exit_finished_failed {
println!("Some processes have failed.");
std::process::exit(101);
}
}
Ok(())
}
fn display_directories(dirs: &[PathBuf]) -> String {
match dirs.len() {
1 => format!("directory: {}", dirs.first().unwrap().display()),
_ => format!(
"directories:\n{}",
dirs.iter().map(|d| format!("* {}", d.display())).join("\n")
),
}
}