justfile with export method for SSG

This commit is contained in:
Michal Vanko 2024-01-30 23:27:02 +01:00
parent 2d548e83ba
commit 8892624e9a
2 changed files with 35 additions and 0 deletions

View File

@ -12,3 +12,6 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information # MSVC Windows builds of rustc generate these, which store debugging information
*.pdb *.pdb
# `dist` folder with the export of SSG
dist/

32
axum_server/justfile Normal file
View File

@ -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