Merge branch 'master' into master

pull/369/head
Chris 2024-07-02 19:36:45 -05:00 zatwierdzone przez GitHub
commit 5b6131a95c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
9 zmienionych plików z 63 dodań i 2 usunięć

Wyświetl plik

@ -71,6 +71,8 @@ Also, keep in mind that using `nginx` caching with a `static` website worker wil
* `NGINX_INCLUDE_FILE`: a file in the app's dir to include in nginx config `server` section - useful for including custom `nginx` directives.
* `NGINX_ALLOW_GIT_FOLDERS`: (boolean) allow access to `.git` folders (default: false, blocked)
* `NGINX_CATCH_ALL` (string, defaults to ""): specifies a filename to serve to all requests regardless of path (useful when using client-side routing)
## Acme Settings

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(())
}

24
piku.py
Wyświetl plik

@ -171,7 +171,7 @@ PIKU_INTERNAL_NGINX_STATIC_MAPPING = """
directio 8m;
aio threads;
alias $static_path;
try_files $uri $uri.html $uri/ =404;
try_files $uri $uri.html $uri/ $catch_all =404;
}
"""
@ -403,7 +403,7 @@ def do_deploy(app, deltas={}, newrev=None):
settings.update(deploy_java_maven(app, deltas))
elif exists(join(app_path, 'build.gradle')) and found_app("Java Gradle") and check_requirements(['java', 'gradle']):
settings.update(deploy_java_gradle(app, deltas))
elif (exists(join(app_path, 'Godeps')) or len(glob(join(app_path, '*.go')))) and found_app("Go") and check_requirements(['go']):
elif (exists(join(app_path, 'Godeps')) or exists(join(app_path, 'go.mod')) or len(glob(join(app_path, '*.go')))) and found_app("Go") and check_requirements(['go']):
settings.update(deploy_go(app, deltas))
elif exists(join(app_path, 'deps.edn')) and found_app("Clojure CLI") and check_requirements(['java', 'clojure']):
settings.update(deploy_clojure_cli(app, deltas))
@ -412,6 +412,8 @@ def do_deploy(app, deltas={}, newrev=None):
elif 'php' in workers:
echo("-----> PHP app detected.", fg='green')
settings.update(deploy_identity(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))
@ -569,6 +571,7 @@ def deploy_go(app, deltas={}):
go_path = join(ENV_ROOT, app)
deps = join(APP_ROOT, app, 'Godeps')
go_mod = join(APP_ROOT, app, 'go.mod')
first_time = False
if not exists(go_path):
@ -588,6 +591,20 @@ def deploy_go(app, deltas={}):
'GO15VENDOREXPERIMENT': '1'
}
call('godep update ...', cwd=join(APP_ROOT, app), env=env, shell=True)
if exists(go_mod):
echo("-----> Running go mod tidy for '{}'".format(app), fg='green')
call('go mod tidy', cwd=join(APP_ROOT, app), shell=True)
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)
@ -717,6 +734,7 @@ def spawn_app(app, deltas={}):
env = {
'APP': app,
'LOG_ROOT': LOG_ROOT,
'DATA_ROOT': join(DATA_ROOT, app),
'HOME': environ['HOME'],
'USER': environ['USER'],
'PATH': ':'.join([join(virtualenv_path, 'bin'), environ['PATH']]),
@ -937,6 +955,8 @@ def spawn_app(app, deltas={}):
static_paths = ("/" if stripped[0:1] == ":" else "/:") + (stripped if stripped else ".") + "/" + ("," if static_paths else "") + static_paths
if len(static_paths):
try:
# pylint: disable=unused-variable
catch_all = env.get('NGINX_CATCH_ALL', '')
items = static_paths.split(',')
for item in items:
static_url, static_path = item.split(':')