From 8892624e9ad32b49769f3bd4c604c1a828d40e58 Mon Sep 17 00:00:00 2001 From: Michal Vanko Date: Tue, 30 Jan 2024 23:27:02 +0100 Subject: [PATCH] justfile with export method for SSG --- axum_server/.gitignore | 3 +++ axum_server/justfile | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 axum_server/justfile diff --git a/axum_server/.gitignore b/axum_server/.gitignore index 6985cf1..b91269d 100644 --- a/axum_server/.gitignore +++ b/axum_server/.gitignore @@ -12,3 +12,6 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + +# `dist` folder with the export of SSG +dist/ diff --git a/axum_server/justfile b/axum_server/justfile new file mode 100644 index 0000000..fc067d4 --- /dev/null +++ b/axum_server/justfile @@ -0,0 +1,32 @@ +port := env_var_or_default('PORT', '3080') + +# Run dev server in watch mode +dev: + cargo watch -x run + +# Run server in production mode +prod: + cargo run --release + +# Wait for port to listen to connections +wait_for_port: + #!/usr/bin/env bash + set -euxo pipefail + while ! nc -z localhost {{port}}; do + sleep 3 + done + +# Kill the application running on port +kill: + kill $(lsof -t -i:{{port}}) + +# Clean the dist folder +clean: + rm -rf dist + +# SSG export of production server +export: clean + just prod & + just wait_for_port + - wget --convert-links -r -p --level 1 -E -P dist --no-host-directories localhost:{{port}} + just kill