Add busybox http server

This commit is contained in:
Starbeamrainbowlabs 2020-05-09 13:10:19 +01:00
parent 3f1548201b
commit 4173749455
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

27
build
View file

@ -17,6 +17,7 @@ lantern_path="./lantern-build-engine";
config="./.eleventy.js"; # relative to src/ config="./.eleventy.js"; # relative to src/
output_dir="${PWD}/public"; output_dir="${PWD}/public";
port_number="5726"
############################################################################### ###############################################################################
@ -37,6 +38,8 @@ if [[ "$#" -lt 1 ]]; then
echo -e " ${CACTION}setup${RS} - Perform initial setup"; echo -e " ${CACTION}setup${RS} - Perform initial setup";
echo -e " ${CACTION}build${RS} - Build the static site"; echo -e " ${CACTION}build${RS} - Build the static site";
echo -e " ${CACTION}watch${RS} - Watch for changes and rebuild automatically"; echo -e " ${CACTION}watch${RS} - Watch for changes and rebuild automatically";
echo -e " ${CACTION}server${RS} - Start a development busybox http server";
echo -e " ${CACTION}launch${RS} - Do both ${CACTION}server${RS} and ${CACTION}watch${RS}";
echo -e " ${CACTION}serve${RS} - Start a livereload server"; echo -e " ${CACTION}serve${RS} - Start a livereload server";
echo -e ""; echo -e "";
@ -84,6 +87,30 @@ task_watch() {
stage_end 0; stage_end 0;
done done
} }
task_server() {
task_begin "Starting server";
busybox httpd -vv -f -p "${port_number}" -h "${output_dir}" &
pid="$!"
task_end "$?";
echo -e "Server started on ${HC}http://$(hostname -I | tr ' ' '\n' | head -n1):${port_number}/${RS}"
on_exit() {
task_begin "Stopping server";
kill "${pid}";
task_end "$?";
}
trap on_exit EXIT;
wait
}
task_launch() {
tasks_run server &
tasks_run watch &
wait
}
task_serve() { task_serve() {
tasks_run watch & tasks_run watch &
sleep 0.2; sleep 0.2;