942eb7c3d8
This is a major breaking change that moves away from having the entire app configuration in external TOML files to settings being in the database with a UI to update them dynamically. The app loads all config into memory (app settings, SMTP conf) on boot. "Hot" replacing them is complex and it's a fair tradeoff to instead just restart the application as it is practically instant. A new `settings` table stores arbitrary string keys with a JSONB value field which happens to support arbitrary types. After every settings update, the app gracefully releases all resources (HTTP server, DB pool, SMTP pool etc.) and restarts itself, occupying the same PID. If there are any running campaigns, the auto-restart doesn't happen and the user is prompted to invoke it manually with a one-click button once all running campaigns have been paused.
53 lines
1.4 KiB
Makefile
53 lines
1.4 KiB
Makefile
LAST_COMMIT := $(shell git rev-parse --short HEAD)
|
|
LAST_COMMIT_DATE := $(shell git show -s --format=%ci ${LAST_COMMIT})
|
|
VERSION := $(shell git describe)
|
|
BUILDSTR := ${VERSION} (${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
|
|
|
|
BIN := listmonk
|
|
STATIC := config.toml.sample \
|
|
schema.sql queries.sql \
|
|
static/public:/public \
|
|
static/email-templates \
|
|
frontend/dist:/frontend \
|
|
frontend/dist/frontend:/frontend
|
|
|
|
# Dependencies.
|
|
.PHONY: deps
|
|
deps:
|
|
go get -u github.com/knadh/stuffbin/...
|
|
cd frontend && yarn install
|
|
|
|
# Build steps.
|
|
.PHONY: build
|
|
build:
|
|
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}'"
|
|
|
|
.PHONY: build-frontend
|
|
build-frontend:
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build
|
|
|
|
.PHONY: run
|
|
run: build
|
|
./${BIN}
|
|
|
|
.PHONY: run-frontend
|
|
run-frontend:
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
|
|
|
|
.PHONY: test
|
|
test:
|
|
go test ./...
|
|
|
|
# dist builds the backend, frontend, and uses stuffbin to
|
|
# embed all frontend assets into the binary.
|
|
.PHONY: dist
|
|
dist: build build-frontend
|
|
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
|
|
|
# pack-releases runns stuffbin packing on a given list of
|
|
# binaries. This is used with goreleaser for packing
|
|
# release builds for cross-build targets.
|
|
.PHONY: pack-releases
|
|
pack-releases:
|
|
$(foreach var,$(RELEASE_BUILDS),stuffbin -a stuff -in ${var} -out ${var} ${STATIC} $(var);)
|
|
|