This commit is contained in:
11
README.md
11
README.md
@@ -20,3 +20,14 @@ The service runs the stable build artifact at:
|
|||||||
```text
|
```text
|
||||||
/home/zaine/master-folder/projects/java_projects/org_backend/target/org-backend.jar
|
/home/zaine/master-folder/projects/java_projects/org_backend/target/org-backend.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Runtime configuration is loaded by systemd from:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/etc/org-backend/org-backend.env
|
||||||
|
```
|
||||||
|
|
||||||
|
Create that file once on the server from `misc/org-backend.env.example` and
|
||||||
|
fill in the production values. The Gitea deploy step installs an updated
|
||||||
|
example file to `/etc/org-backend/org-backend.env.example`, but it does not
|
||||||
|
overwrite the real env file.
|
||||||
|
|||||||
23
misc/org-backend.env.example
Normal file
23
misc/org-backend.env.example
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Copy this file to /etc/org-backend/org-backend.env on the server and fill in
|
||||||
|
# production values. This file is safe to commit only with placeholder values.
|
||||||
|
|
||||||
|
SERVER_PORT=9010
|
||||||
|
|
||||||
|
SPRING_DATASOURCE_URL=jdbc:postgresql://127.0.0.1:5432/org_web
|
||||||
|
SPRING_DATASOURCE_USERNAME=org_backend
|
||||||
|
SPRING_DATASOURCE_PASSWORD=change-me
|
||||||
|
SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
|
||||||
|
SPRING_JPA_SHOW_SQL=false
|
||||||
|
|
||||||
|
CALIBRE_DB_PATH=/home/zaine/master-folder/projects/calibre/library/metadata.db
|
||||||
|
|
||||||
|
JWT_SECRET=change-me-to-a-long-random-secret-at-least-32-characters
|
||||||
|
JWT_EXPIRATION_MS=86400000
|
||||||
|
|
||||||
|
ZONE_BUILD_DIR=/home/zaine/master-folder/org_files/org_web
|
||||||
|
ZONE_BUILD_LOG=/home/zaine/master-folder/org_files/org_web/org-web-build.log
|
||||||
|
ORGROAM_BUILD_DIR=/home/zaine/master-folder/org_files/org_roam
|
||||||
|
ORGROAM_BUILD_LOG=/home/zaine/master-folder/org_files/org_roam/orgroam-build.log
|
||||||
|
EMACS_RUN_DIR=/home/zaine
|
||||||
|
EMACS_RUN_LOG=/home/zaine/logs/emacs.log
|
||||||
|
COMBINED_RUN_LOG=/home/zaine/logs/combined.log
|
||||||
@@ -6,6 +6,7 @@ After=network.target
|
|||||||
User=zaine
|
User=zaine
|
||||||
Group=zaine
|
Group=zaine
|
||||||
Environment=SPRING_PROFILES_ACTIVE=prod
|
Environment=SPRING_PROFILES_ACTIVE=prod
|
||||||
|
EnvironmentFile=/etc/org-backend/org-backend.env
|
||||||
|
|
||||||
WorkingDirectory=/home/zaine/master-folder/projects/java_projects/org_backend
|
WorkingDirectory=/home/zaine/master-folder/projects/java_projects/org_backend
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ set -euo pipefail
|
|||||||
APP_HOME="${APP_HOME:-/home/zaine/master-folder/projects/java_projects/org_backend}"
|
APP_HOME="${APP_HOME:-/home/zaine/master-folder/projects/java_projects/org_backend}"
|
||||||
SERVICE_NAME="${SERVICE_NAME:-org-backend.service}"
|
SERVICE_NAME="${SERVICE_NAME:-org-backend.service}"
|
||||||
SYSTEMCTL_TIMEOUT="${SYSTEMCTL_TIMEOUT:-120}"
|
SYSTEMCTL_TIMEOUT="${SYSTEMCTL_TIMEOUT:-120}"
|
||||||
|
ENV_FILE="${ENV_FILE:-/etc/org-backend/org-backend.env}"
|
||||||
|
ENV_EXAMPLE_FILE="${ENV_EXAMPLE_FILE:-/etc/org-backend/org-backend.env.example}"
|
||||||
|
|
||||||
SOURCE_DIR="$(pwd)"
|
SOURCE_DIR="$(pwd)"
|
||||||
SOURCE_JAR="${SOURCE_DIR}/target/org-backend.jar"
|
SOURCE_JAR="${SOURCE_DIR}/target/org-backend.jar"
|
||||||
APP_TARGET_DIR="${APP_HOME}/target"
|
APP_TARGET_DIR="${APP_HOME}/target"
|
||||||
APP_JAR="${APP_TARGET_DIR}/org-backend.jar"
|
APP_JAR="${APP_TARGET_DIR}/org-backend.jar"
|
||||||
SOURCE_SERVICE="${SOURCE_DIR}/misc/${SERVICE_NAME}"
|
SOURCE_SERVICE="${SOURCE_DIR}/misc/${SERVICE_NAME}"
|
||||||
|
SOURCE_ENV_EXAMPLE="${SOURCE_DIR}/misc/org-backend.env.example"
|
||||||
SYSTEMD_SERVICE="/etc/systemd/system/${SERVICE_NAME}"
|
SYSTEMD_SERVICE="/etc/systemd/system/${SERVICE_NAME}"
|
||||||
|
|
||||||
run_sudo() {
|
run_sudo() {
|
||||||
@@ -30,6 +33,11 @@ if [[ ! -f "${SOURCE_SERVICE}" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "${SOURCE_ENV_EXAMPLE}" ]]; then
|
||||||
|
echo "Missing env example file: ${SOURCE_ENV_EXAMPLE}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "${APP_TARGET_DIR}"
|
mkdir -p "${APP_TARGET_DIR}"
|
||||||
|
|
||||||
if [[ "$(realpath "${SOURCE_JAR}")" != "$(realpath -m "${APP_JAR}")" ]]; then
|
if [[ "$(realpath "${SOURCE_JAR}")" != "$(realpath -m "${APP_JAR}")" ]]; then
|
||||||
@@ -42,6 +50,16 @@ fi
|
|||||||
echo "Checking sudo access"
|
echo "Checking sudo access"
|
||||||
run_sudo true
|
run_sudo true
|
||||||
|
|
||||||
|
echo "Installing env example to ${ENV_EXAMPLE_FILE}"
|
||||||
|
run_sudo install -d -m 0755 "$(dirname "${ENV_FILE}")"
|
||||||
|
run_sudo install -m 0640 "${SOURCE_ENV_EXAMPLE}" "${ENV_EXAMPLE_FILE}"
|
||||||
|
|
||||||
|
echo "Checking runtime env file at ${ENV_FILE}"
|
||||||
|
if ! run_sudo test -f "${ENV_FILE}"; then
|
||||||
|
echo "Missing ${ENV_FILE}. Create it from ${ENV_EXAMPLE_FILE} and fill in the production values." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Installing systemd unit to ${SYSTEMD_SERVICE}"
|
echo "Installing systemd unit to ${SYSTEMD_SERVICE}"
|
||||||
run_sudo install -m 0644 "${SOURCE_SERVICE}" "${SYSTEMD_SERVICE}"
|
run_sudo install -m 0644 "${SOURCE_SERVICE}" "${SYSTEMD_SERVICE}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user