hotfix + docker for proxy

migrate
prplV 2025-06-06 05:31:09 -04:00
parent 0634ecd0d3
commit 4133d2f348
5 changed files with 47 additions and 4 deletions

View File

@ -0,0 +1,4 @@
.env
.env.example
README.md
target

19
noxis-proxy/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM rust:latest AS builder
WORKDIR /app
RUN apt update && apt install -y musl-tools
RUN rustup target add x86_64-unknown-linux-musl
COPY . .
RUN cargo build --release --target=x86_64-unknown-linux-musl
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/noxis-proxy /app/noxis-proxy
RUN apk add --no-cache ca-certificates
EXPOSE 7654
ENTRYPOINT ["/app/noxis-proxy"]

View File

@ -0,0 +1,20 @@
services:
noxis-proxy:
container_name: noxis-proxy
image: noxis-proxy:0.1.0
networks:
- noxis-net
environment:
- NOXIS_SOCKET_PATH=./noxis.sock
- NOXIS_PROXY_PORT=7654
- NOXIS_LOG_LEVEL=TRACE
volumes:
- /home/user/diplom_code/noxis-rs/noxis.sock:/app/noxis.sock
ports:
- 7654:7654
restart: always
networks:
noxis-net:
driver: bridge

View File

@ -36,7 +36,7 @@ async fn main() -> anyhow::Result<()> {
.route("/hello", get(hello)) .route("/hello", get(hello))
.with_state(app_state); .with_state(app_state);
let bind = format!("0.0.0.0:{}", std::env::var("NOXIS_PROXY_PORT").unwrap_or_else(|_| String::from("3000"))); let bind = format!("0.0.0.0:{}", std::env::var("NOXIS_PROXY_PORT").unwrap_or_else(|_| String::from("7654")));
tracing::info!("Serving on {}", &bind); tracing::info!("Serving on {}", &bind);
@ -68,14 +68,14 @@ async fn handle_socket(mut ws: WebSocket, state: AppState) {
let mut unix_socket = match UnixStream::connect(&state.socket_path).await { let mut unix_socket = match UnixStream::connect(&state.socket_path).await {
Ok(socket) => socket, Ok(socket) => socket,
Err(e) => { Err(e) => {
eprintln!("Failed to connect to Unix socket: {}", e); tracing::error!("Failed to connect to Unix socket: {}", e);
let _ = ws.send(Message::Text("ERROR: Unix socket connection failed".into())).await; let _ = ws.send(Message::Text("ERROR: Unix socket connection failed".into())).await;
return; return;
} }
}; };
if let Message::Text(text) = msg { if let Message::Text(text) = msg {
if let Err(e) = unix_socket.write_all(text.as_bytes()).await { if let Err(e) = unix_socket.write_all(text.as_bytes()).await {
eprintln!("Failed to write to Unix socket: {}", e); tracing::error!("Failed to write to Unix socket: {}", e);
break; break;
} }
let mut buf = Vec::new(); let mut buf = Vec::new();

View File

@ -49,7 +49,7 @@ pub mod v2 {
ServicesController { ServicesController {
name: String::new(), name: String::new(),
access_url: Arc::from(String::new()), access_url: Arc::from(String::new()),
state: ServiceState::Unavailable, state: ServiceState::Ok,
config: ConnectionQueue::new(), config: ConnectionQueue::new(),
event_registrator: EventHandlers::new(), event_registrator: EventHandlers::new(),
} }