diff --git a/Dockerfile b/Dockerfile index 2bde94e3d077154f84bdf77a022c9aa49cdadac7..fc6d1e42cf75c7a80230263f203f6414cc8e721b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,11 +19,11 @@ RUN yarn build FROM docker.io/library/alpine:latest -ARG SPOCCIFY_HTTP_BIND_HOST 0.0.0.0 -ARG SPOCCIFY_HTTP_BIND_PORT 9000 +ENV SPOCCIFY_HTTP_BIND_HOST 0.0.0.0 +ENV SPOCCIFY_HTTP_BIND_PORT 9000 -ARG SPOCCIFY_WEBSOCKET_BIND_HOST 0.0.0.0 -ARG SPOCCIFY_WEBSOCKET_BIND_PORT 9001 +ENV SPOCCIFY_WEBSOCKETS_BIND_HOST 0.0.0.0 +ENV SPOCCIFY_WEBSOCKETS_BIND_PORT 9001 RUN apk add ffmpeg yt-dlp COPY --from=builder-backend /usr/src/spoccify/target/release/spoccify /spoccify/spoccify diff --git a/src/http.rs b/src/http.rs index 5d2a982a2b8dd8d0b365be6a653193f781281197..244cb0ce5d50a6e78b695183a948962a8b9ecf72 100644 --- a/src/http.rs +++ b/src/http.rs @@ -10,7 +10,7 @@ use tower_http::services::ServeDir; // use crate::song::Song; -pub async fn handle_http(http_bind_address: &str, /* playlist_websocket: &Mutable<Vec<Song>> */) { +pub async fn handle_http(http_bind_address: &str, /* playlist: &Mutable<Vec<Song>> */) { println!("Listening for http connections on {}!", http_bind_address); async fn handle_404() -> (StatusCode, &'static str) { diff --git a/src/main.rs b/src/main.rs index 15c15a4ea95bef85e90ceb1e988c246afd579882..5ae06ecee25c94b3ae0fb32eaa52d518cb6457f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ mod http; mod player; mod song; mod util; -mod websocket; +mod websockets; mod websocket_command; use futures_signals::signal::Mutable; @@ -34,17 +34,17 @@ async fn main() { let client_token = Arc::new(env::var("SPOCCIFY_CLIENT_TOKEN").expect("No client token provided!")); - let websocket_bind_host = - env::var("SPOCCIFY_WEBSOCKET_BIND_HOST").unwrap_or("127.0.0.1".to_owned()); - let websocket_bind_port = env::var("SPOCCIFY_WEBSOCKET_BIND_PORT").unwrap_or("9001".to_owned()); + let websockets_bind_host = + env::var("SPOCCIFY_WEBSOCKETS_BIND_HOST").unwrap_or("127.0.0.1".to_owned()); + let websockets_bind_port = env::var("SPOCCIFY_WEBSOCKETS_BIND_PORT").unwrap_or("9001".to_owned()); - let websocket_bind_address = format!("{}:{}", websocket_bind_host, websocket_bind_port); + let websockets_bind_address = format!("{}:{}", websockets_bind_host, websockets_bind_port); let _websockets_task = tokio::task::spawn(async move { - websocket::handle_websockets( + websockets::handle_websockets( &player_token, &client_token, - &websocket_bind_address, + &websockets_bind_address, &playlist_websockets, ) .await; diff --git a/src/websocket.rs b/src/websockets.rs similarity index 93% rename from src/websocket.rs rename to src/websockets.rs index 48bbc72fb224d09e45d9feba1f15b7b040515f4b..bb5b055d329622fde008b1a68f3ee500178b9011 100644 --- a/src/websocket.rs +++ b/src/websockets.rs @@ -13,14 +13,14 @@ use crate::song::Song; pub async fn handle_websockets( player_token: &Arc<String>, client_token: &Arc<String>, - websocket_bind_address: &str, + websockets_bind_address: &str, playlist_websocket: &Mutable<Vec<Song>>, ) { - let server = TcpListener::bind(websocket_bind_address).expect("Failed to bind websocket port!"); + let server = TcpListener::bind(websockets_bind_address).expect("Failed to bind websocket port!"); println!( "Listening for websocket connections on {}!", - websocket_bind_address + websockets_bind_address ); for stream in server.incoming() {