From 36738c0d4ddbc80815981ef83a06bfc115dc1aef Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Tue, 28 Jan 2025 17:38:15 -0700 Subject: [PATCH] Autoconf/Make nearing completion --- .gitignore | 4 ++- Makefile.in | 35 +++++++++++++++++------- backend/Makefile.in | 11 ++++---- backend/src/scheduler.scm | 30 ++++++++++---------- backend/src/spawn_interaction.scm | 8 +++--- configure | 6 +++- configure.in | 4 ++- frontend/Makefile.in | 11 +++++--- nginx/{yacswa.conf.m4 => yacswa.conf.in} | 2 +- 9 files changed, 69 insertions(+), 42 deletions(-) rename nginx/{yacswa.conf.m4 => yacswa.conf.in} (95%) diff --git a/.gitignore b/.gitignore index 52e99db..e55b427 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ backend/repo/ # autoconf products **/Makefile +nginx/yacswa.conf configure.scan config.log -config.status \ No newline at end of file +config.status +autom4te.cache/ \ No newline at end of file diff --git a/Makefile.in b/Makefile.in index 9001e79..a1d968f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,22 +1,37 @@ -.PHONY: all back front install +.PHONY: all back front install up down clean all: back front back: - cd backend && ${MAKE} + @echo "Building backend..." + @cd backend && ${MAKE} front: - cd frontend && ${MAKE} + @echo "Building frontend..." + @cd frontend && ${MAKE} @public_dir@: - cd frontend && ${MAKE} install + @echo "Installing frontend assets..." + @cd frontend && sudo ${MAKE} install -@nginx_config@: m4/environment.m4 nginx/yacswa.conf.m4 - m4 m4/environment.m4 nginx/yacswa.conf.m4 > @nginx_config@ +@nginx_dir@sites_available/@nginx_config@: nginx/yacswa.conf + @echo "Installing nginx config..." + @mkdir -p @nginx_dir@sites_available + @cp nginx/yacswa.conf @nginx_dir@sites_available/@nginx_config@ -install: @public_dir@ @nginx_config@ +install: @public_dir@ @nginx_dir@sites_available/@nginx_config@ -up: install - sudo $(LN_S) /etc/nginx/sites_available/yacswa.conf /etc/nginx/sites_enabled/ - cd backend && ${MAKE} up +up: install @nginx_dir@sites_enabled/@nginx_config@ + @cd backend && ${MAKE} up + +@nginx_dir@sites_enabled/@nginx_config@: + @sudo mkdir -p @nginx_dir@sites_enabled + @sudo @LN_S@ @nginx_dir@sites_available/@nginx_config@ @nginx_dir@sites_enabled/ + +down: + @sudo rm -f @nginx_dir@sites_enabled/@nginx_config@ + @cd backend && ${MAKE} down + +clean: + @cd frontend && make clean diff --git a/backend/Makefile.in b/backend/Makefile.in index 4416e03..58bd07b 100644 --- a/backend/Makefile.in +++ b/backend/Makefile.in @@ -6,15 +6,16 @@ all: deps deps: tk csv tk: - cd deps/guile-toolkit && ${MAKE} && sudo ${MAKE} install + @cd deps/guile-toolkit && ${MAKE} && sudo ${MAKE} install csv: - cd deps/guile-csv && ${MAKE} && sudo ${MAKE} install + @cd deps/guile-csv && ${MAKE} && sudo ${MAKE} install -up: deps .backend.lock +up: .backend.lock .backend.lock: main.scm - @nohup $(GUILE) ./main.scm > yacswa-backend.log & export PID=$$! & echo "Server spawned with PID $${PID}"; echo $${PID} > .backend.lock; unset PID + @@GUILE@ ./main.scm > yacswa-backend.log & export PID=$$!; echo $${PID} > .backend.lock + @echo "Server spawned with PID $${PID}" && echo $${PID} > .backend.lock && unset PID down: - @export PID=`cat .backend.lock`; kill -15 $${PID}; rm .backend.lock; echo "Server on PID $${PID} down."; unset PID + @export PID=`cat .backend.lock` && kill -15 $${PID} && rm .backend.lock && echo "Server on PID $${PID} down."; unset PID diff --git a/backend/src/scheduler.scm b/backend/src/scheduler.scm index f09fb89..3bd3e36 100644 --- a/backend/src/scheduler.scm +++ b/backend/src/scheduler.scm @@ -122,21 +122,21 @@ (sleep (sec/mins 9)))) (loop))) -#! As the git repository is no longer updated there is no need to - establish a job loop or populate the statistics tables asynchronously - -(begin-thread (with-mutex %json-lock - (git:fetch) - (set! mcron-locked (mutex-owner %json-lock)) - (process-stats! $stat-tree) - (calculate-strings!)) - (sleep (next-timestamp)) - (job-loop)) - -(sleep 1) -(while (mutex-locked? %json-lock) - (sleep 1)) -!# +;; As the git repository is no longer updated there is no need to +;; establish a job loop or populate the statistics tables asynchronously + +;;(begin-thread (with-mutex %json-lock +;; (git:fetch) +;; (set! mcron-locked (mutex-owner %json-lock)) +;; (process-stats! $stat-tree) +;; (calculate-strings!)) +;; (sleep (next-timestamp)) +;; (job-loop)) + +;;(sleep 1) +;;(while (mutex-locked? %json-lock) +;; (sleep 1)) + ; Functional parts of the asynchronous code above (git:fetch) diff --git a/backend/src/spawn_interaction.scm b/backend/src/spawn_interaction.scm index 9931eb4..442c0a8 100644 --- a/backend/src/spawn_interaction.scm +++ b/backend/src/spawn_interaction.scm @@ -8,10 +8,10 @@ ;; : ;; Backchannel -#! -(define repl-sock (make-unix-domain-server-socket #:path "./bc")) -(spawn-server repl-sock) -!# + +;;(define repl-sock (make-unix-domain-server-socket #:path "./bc")) +;;(spawn-server repl-sock) + ;; endpoint helpers (define (err: text) (scm->json-string `((error . ,text)))) diff --git a/configure b/configure index 482691d..b008fc7 100755 --- a/configure +++ b/configure @@ -617,6 +617,7 @@ GUILD GUILE SET_MAKE nginx_config +nginx_dir public_dir server_name target_alias @@ -1727,6 +1728,8 @@ server_name=yacswa.home public_dir=/srv/yacswa.home +nginx_dir=/etc/nginx/ + nginx_config=yacswa.home.conf @@ -1957,7 +1960,7 @@ fi -ac_config_files="$ac_config_files Makefile backend/Makefile frontend/Makefile" +ac_config_files="$ac_config_files Makefile backend/Makefile frontend/Makefile nginx/yacswa.conf" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -2663,6 +2666,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "backend/Makefile") CONFIG_FILES="$CONFIG_FILES backend/Makefile" ;; "frontend/Makefile") CONFIG_FILES="$CONFIG_FILES frontend/Makefile" ;; + "nginx/yacswa.conf") CONFIG_FILES="$CONFIG_FILES nginx/yacswa.conf" ;; *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.in b/configure.in index 9725c82..4833579 100644 --- a/configure.in +++ b/configure.in @@ -7,6 +7,7 @@ AC_INIT([Yet Another Covid Statistics Web App], [1.0], [me@bradymcd.ca]) # Pull in environment variables AC_SUBST([server_name], [yacswa.home]) AC_SUBST([public_dir], [/srv/yacswa.home]) +AC_SUBST([nginx_dir], [/etc/nginx/]) AC_SUBST([nginx_config], [yacswa.home.conf]) # Checks for programs. @@ -24,5 +25,6 @@ AC_PROG_LN_S AC_CONFIG_FILES([Makefile backend/Makefile - frontend/Makefile]) + frontend/Makefile + nginx/yacswa.conf]) AC_OUTPUT diff --git a/frontend/Makefile.in b/frontend/Makefile.in index 8c8a03e..8e3a875 100644 --- a/frontend/Makefile.in +++ b/frontend/Makefile.in @@ -1,16 +1,19 @@ -.PHONY: all +.PHONY: all clean all: www/elm.js www/elm.js: - $(ELM) make src/Main.elm --output=www/elm.js + @ELM@ make src/Main.elm --output=www/elm.js install: www/elm.js @public_dir@ @public_dir@: - mkdir @public_dir@ - cp ./www/ @public_dir@ + @mkdir -p @public_dir@ + @cp -r ./www/ @public_dir@ uninstall: rm -rf @public_dir@ + +clean: + rm -f www/elm.js diff --git a/nginx/yacswa.conf.m4 b/nginx/yacswa.conf.in similarity index 95% rename from nginx/yacswa.conf.m4 rename to nginx/yacswa.conf.in index b13aa43..bf8cebc 100644 --- a/nginx/yacswa.conf.m4 +++ b/nginx/yacswa.conf.in @@ -5,7 +5,7 @@ server { server_name @server_name@ www.@server_name@; - root _PUBLIC_DIR_; + root @public_dir@; try_files $uri $uri/ /not_found; location /json/pc {