load config on channel save, fix docker paths

This commit is contained in:
jb-alvarado 2024-08-22 17:23:39 +02:00
parent 41e531f963
commit 01719a92c3
8 changed files with 47 additions and 14 deletions

View File

@ -1,6 +1,6 @@
FROM alpine:latest
ARG FFPLAYOUT_VERSION=0.24.0-beta1
ARG FFPLAYOUT_VERSION=0.24.0-beta2
ARG SHARED_STORAGE=false
ENV DB=/db
@ -12,7 +12,7 @@ COPY <<-EOT /run.sh
#!/bin/sh
if [ ! -f /db/ffplayout.db ]; then
ffplayout -u admin -p admin -m contact@example.com --storage-path "/tv-media" --playlist-path "/playlists" --hls-path "/hls" --log-path "/logging" --shared-storage
ffplayout -u admin -p admin -m contact@example.com --storage-root "/tv-media" --playlist-root "/playlists" --public-root "/public" --log-path "/logging" --shared-storage
fi
/usr/bin/ffplayout -l "0.0.0.0:8787"

View File

@ -39,7 +39,7 @@ docker build -f nvidia.Dockerfile -t ffplayout-image:nvidia .
example of command to start the container:
```BASH
docker run -it -v /path/to/db:/db -v /path/to/storage:/tv-media -v /path/to/playlists:/playlists -v /path/to/hls:/hls -v /path/to/logging:/logging --name ffplayout -p 8787:8787 ffplayout-image
docker run -it -v /path/to/db:/db -v /path/to/storage:/tv-media -v /path/to/playlists:/playlists -v /path/to/public:/public -v /path/to/logging:/logging --name ffplayout -p 8787:8787 ffplayout-image
# run in daemon mode
docker run -d --name ffplayout -p 8787:8787 ffplayout-image

View File

@ -11,6 +11,6 @@ services:
- ./data/storage:/tv-media
- ./data/playlists:/playlists
- ./data/logging:/logging
- ./data/hls:/hls
- ./data/public:/public
ports:
- '8787:8787'

View File

@ -1,6 +1,6 @@
FROM alpine:latest
ARG FFPLAYOUT_VERSION=0.24.0-beta1
ARG FFPLAYOUT_VERSION=0.24.0-beta2
ARG SHARED_STORAGE=false
ENV DB=/db
@ -14,7 +14,7 @@ COPY <<-EOT /run.sh
#!/bin/sh
if [ ! -f /db/ffplayout.db ]; then
ffplayout -u admin -p admin -m contact@example.com --storage-path "/tv-media" --playlist-path "/playlists" --hls-path "/hls" --log-path "/logging" --shared-storage
ffplayout -u admin -p admin -m contact@example.com --storage-root "/tv-media" --playlist-root "/playlists" --public-root "/public" --log-path "/logging" --shared-storage
fi
/usr/bin/ffplayout -l "0.0.0.0:8787"

View File

@ -1,6 +1,6 @@
FROM nvidia/cuda:12.5.0-runtime-rockylinux9
ARG FFPLAYOUT_VERSION=0.24.0-beta1
ARG FFPLAYOUT_VERSION=0.24.0-beta2
ARG SHARED_STORAGE=false
ENV DB=/db
@ -204,7 +204,7 @@ COPY <<-EOT /run.sh
#!/bin/sh
if [ ! -f /db/ffplayout.db ]; then
ffplayout -u admin -p admin -m contact@example.com --storage-path "/tv-media" --playlist-path "/playlists" --hls-path "/hls" --log-path "/logging" --shared-storage
ffplayout -u admin -p admin -m contact@example.com --storage-root "/tv-media" --playlist-root "/playlists" --public-root "/public" --log-path "/logging" --shared-storage
fi
/usr/bin/ffplayout -l "0.0.0.0:8787"

View File

@ -475,9 +475,11 @@ async fn patch_channel(
pool: web::Data<Pool<Sqlite>>,
id: web::Path<i32>,
data: web::Json<Channel>,
controllers: web::Data<Mutex<ChannelController>>,
role: AuthDetails<Role>,
user: web::ReqData<UserMeta>,
) -> Result<impl Responder, ServiceError> {
let manager = controllers.lock().unwrap().get(*id).unwrap();
let mut data = data.into_inner();
if !role.has_authority(&Role::GlobalAdmin) {
@ -488,11 +490,11 @@ async fn patch_channel(
data.storage_path = channel.storage_path;
}
if handles::update_channel(&pool, *id, data).await.is_ok() {
return Ok("Update Success");
};
handles::update_channel(&pool, *id, data).await?;
let new_config = get_config(&pool, *id).await?;
manager.update_config(new_config);
Err(ServiceError::InternalServerError)
Ok("Update Success")
}
/// **Create new Channel**

View File

@ -453,8 +453,39 @@ pub async fn run_args(pool: &Pool<Sqlite>) -> Result<(), i32> {
shared_storage: args.shared_storage,
};
let mut channel = handles::select_channel(pool, &1)
.await
.expect("Select Channel 1");
if args.shared_storage {
channel.hls_path = Path::new(&global.public_root)
.join("1")
.to_string_lossy()
.to_string();
channel.playlist_path = Path::new(&global.playlist_root)
.join("1")
.to_string_lossy()
.to_string();
channel.storage_path = Path::new(&global.storage_root)
.join("1")
.to_string_lossy()
.to_string();
} else {
channel.hls_path = global.public_root.clone();
channel.playlist_path = global.playlist_root.clone();
channel.storage_path = global.storage_root.clone();
}
match handles::update_global(pool, global.clone()).await {
Ok(_) => println!("Update global paths..."),
Ok(_) => println!("Update globals done..."),
Err(e) => {
eprintln!("{e}");
error_code = 1;
}
};
match handles::update_channel(pool, 1, channel).await {
Ok(_) => println!("Update channel done..."),
Err(e) => {
eprintln!("{e}");
error_code = 1;

@ -1 +1 @@
Subproject commit e183320e13bd972d632b841bde722fa7bbed70e5
Subproject commit 4d38a74306113431d6b5db10738e0bb2b1a2cf75