This commit is contained in:
parent
78f4cc3965
commit
b5d3e63807
7 changed files with 50 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
output.cast
|
||||
.direnv
|
||||
/logs
|
||||
/result*
|
||||
|
|
|
@ -9,3 +9,31 @@ pipeline:
|
|||
- rustup default $RUST
|
||||
- cargo check
|
||||
- cargo test
|
||||
|
||||
build-docker-image:
|
||||
image: nixos/nix
|
||||
commands:
|
||||
- ls -la
|
||||
- pwd
|
||||
- nix --extra-experimental-features "nix-command flakes" build -o /shared/image.tar.gz .#liveterm-docker
|
||||
volumes:
|
||||
- "liveterm-shared:/shared"
|
||||
when:
|
||||
# event: tag
|
||||
branch: master
|
||||
|
||||
deploy:
|
||||
image: plugins/docker
|
||||
commands:
|
||||
- ls -la
|
||||
- pwd
|
||||
- docker load /shared/image.tar.gz
|
||||
- export REPO=git.mzhang.io/michael/liveterm
|
||||
- export TAG=$(docker images liveterm --format "{{.Tag}}")
|
||||
- docker tag liveterm:$TAG $REPO:$TAG
|
||||
- docker push $REPO:$TAG
|
||||
volumes:
|
||||
- "liveterm-shared:/shared"
|
||||
when:
|
||||
# event: tag
|
||||
branch: master
|
||||
|
|
|
@ -8,7 +8,7 @@ edition = "2021"
|
|||
anyhow = { version = "1.0.68", features = ["backtrace"] }
|
||||
axum = { version = "0.6.4", features = ["ws", "http2", "macros", "headers"] }
|
||||
chrono = "0.4.23"
|
||||
clap = { version = "4.0.32", features = ["derive"] }
|
||||
clap = { version = "4.0.32", features = ["derive", "env"] }
|
||||
dashmap = "5.4.0"
|
||||
derive_builder = "0.12.0"
|
||||
futures = "0.3.25"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
let rustPlatform = makeRustPlatform { inherit (toolchain) cargo rustc; };
|
||||
|
||||
in rustPlatform.buildRustPackage {
|
||||
name = "asciinema";
|
||||
name = "liveterm";
|
||||
src = ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
|
|
13
flake.nix
13
flake.nix
|
@ -11,15 +11,20 @@
|
|||
|
||||
toolchain = pkgs.fenix.default;
|
||||
|
||||
flakePkgs = {
|
||||
asciinema = pkgs.callPackage ./. { inherit toolchain; };
|
||||
flakePkgs = rec {
|
||||
liveterm = pkgs.callPackage ./. { inherit toolchain; };
|
||||
|
||||
liveterm-docker = pkgs.dockerTools.buildImage {
|
||||
name = "liveterm";
|
||||
config = { Cmd = [ "${liveterm}/bin/liveterm" ]; };
|
||||
};
|
||||
};
|
||||
in rec {
|
||||
packages = flake-utils.lib.flattenTree flakePkgs;
|
||||
defaultPackage = packages.asciinema;
|
||||
defaultPackage = packages.liveterm;
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
inputsFrom = with packages; [ asciinema ];
|
||||
inputsFrom = with packages; [ liveterm ];
|
||||
|
||||
packages = (with pkgs; [
|
||||
asciinema
|
||||
|
|
|
@ -14,7 +14,11 @@ use crate::client::terminal::Terminal;
|
|||
use crate::message::Message;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct StreamOpts {}
|
||||
pub struct StreamOpts {
|
||||
/// The broadcast websocket address of the server
|
||||
#[clap(long = "broadcast-url", env = "LIVETERM_BROADCAST_URL")]
|
||||
broadcast_url: Url,
|
||||
}
|
||||
|
||||
pub fn stream_main(opts: StreamOpts) -> Result<()> {
|
||||
let runtime = Runtime::new()?;
|
||||
|
@ -26,9 +30,11 @@ async fn stream_async_main(opts: StreamOpts) -> Result<()> {
|
|||
println!("Hellosu {opts:?}");
|
||||
|
||||
// Open a new websocket connection to the server
|
||||
let url = Url::parse(&"ws://localhost:8200/broadcast").unwrap();
|
||||
// let url = Url::parse(&"ws://localhost:8200/broadcast").unwrap();
|
||||
|
||||
let (ws, _) = connect_async(url).await.context("Failed to connect")?;
|
||||
let (ws, _) = connect_async(&opts.broadcast_url)
|
||||
.await
|
||||
.context("Failed to connect")?;
|
||||
println!("WebSocket handshake has been successfully completed");
|
||||
|
||||
let (mut write, mut read) = ws.split();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anyhow::{Result};
|
||||
use anyhow::Result;
|
||||
use axum::{
|
||||
extract::{
|
||||
ws::{Message as WsMessage, WebSocket},
|
||||
|
|
Loading…
Reference in a new issue