Merge pull request #362 from henrikpersson/rust

Add Rust
pull/369/head^2
Rui Carmo 2024-07-01 09:35:40 +01:00 zatwierdzone przez GitHub
commit efd4e8e59f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
8 zmienionych plików z 50 dodań i 0 usunięć

1
examples/rust/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1 @@
/target

7
examples/rust/Cargo.lock wygenerowano 100644
Wyświetl plik

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "piku-rust"
version = "0.1.0"

Wyświetl plik

@ -0,0 +1,8 @@
[package]
name = "piku-rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

Wyświetl plik

@ -0,0 +1,3 @@
PIKU_AUTO_RESTART=1
PORT=4000
BIND_ADDRESS=127.0.0.1

Wyświetl plik

@ -0,0 +1 @@
web: cargo run

Wyświetl plik

@ -0,0 +1,2 @@
[toolchain]
channel = "1.78.0"

Wyświetl plik

@ -0,0 +1,17 @@
use std::{io::Write, net::TcpListener};
fn main() -> std::io::Result<()> {
let addr = format!("{}:{}",
std::env::var("BIND_ADDRESS").expect("no addr"),
std::env::var("PORT").expect("no port"));
println!("Listening on {}", addr);
let listener = TcpListener::bind(addr)?;
for stream in listener.incoming() {
let mut stream = stream?;
stream.write_all(b"Hello!\n")?;
}
Ok(())
}

11
piku.py
Wyświetl plik

@ -409,6 +409,8 @@ def do_deploy(app, deltas={}, newrev=None):
settings.update(deploy_clojure_cli(app, deltas))
elif exists(join(app_path, 'project.clj')) and found_app("Clojure Lein") and check_requirements(['java', 'lein']):
settings.update(deploy_clojure_leiningen(app, deltas))
elif exists(join(app_path, 'Cargo.toml')) and exists(join(app_path, 'rust-toolchain.toml')) and found_app("Rust") and check_requirements(['rustc', 'cargo']):
settings.update(deploy_rust(app, deltas))
elif 'release' in workers and 'web' in workers:
echo("-----> Generic app detected.", fg='green')
settings.update(deploy_identity(app, deltas))
@ -588,6 +590,15 @@ def deploy_go(app, deltas={}):
return spawn_app(app, deltas)
def deploy_rust(app, deltas={}):
"""Deploy a Rust application"""
app_path = join(APP_ROOT, app)
echo("-----> Running cargo build for '{}'".format(app), fg='green')
call('cargo build', cwd=app_path, shell=True)
return spawn_app(app, deltas)
def deploy_node(app, deltas={}):
"""Deploy a Node application"""