Compare commits

..
Author SHA1 Message Date
Rögl-Brunner Michel 2807f7fa89 Kan: build and run the API service
Kan v0.8.0 split the app into apps/web and apps/api. The web app proxies
all API and auth calls to a separate API process on port 4000, which the
script neither built nor started, so sign-up failed with 502.

- Bundle the API with apps/api/build.mjs and run it as kan-api.service
- Order kan.service after kan-api.service
- Update: build the API, stop/start both services, and create the API
  service on existing installs
- Use TRELLO_APP_SECRET, the name upstream reads
2026-11-30 13:07:59 +01:00
4 changed files with 66 additions and 14 deletions

No files matched your search

+38 -6
View File
@@ -31,12 +31,41 @@ function update_script() {
exit
fi
if [[ ! -f /etc/systemd/system/kan-api.service ]]; then
msg_info "Creating API Service"
cat <<EOF >/etc/systemd/system/kan-api.service
[Unit]
Description=Kan API
After=network.target postgresql.service
Requires=postgresql.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/kan/apps/api/dist
EnvironmentFile=/opt/kan/.env
ExecStart=/usr/bin/node main.mjs
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
if [[ -f /opt/kan/apps/api/build.mjs ]]; then
cd /opt/kan/apps/api
$STD node build.mjs
systemctl enable -q --now kan-api
fi
msg_ok "Created API Service"
fi
if check_for_gh_tag "kan" "kanbn/kan"; then
NODE_VERSION="24" NODE_MODULE="pnpm" setup_nodejs
msg_info "Stopping Service"
systemctl stop kan
msg_ok "Stopped Service"
msg_info "Stopping Services"
systemctl stop kan kan-api
msg_ok "Stopped Services"
create_backup /opt/kan/.env
CLEAN_INSTALL=1 fetch_and_deploy_gh_tag "kan" "kanbn/kan" "latest"
@@ -50,6 +79,8 @@ function update_script() {
export CI=true
find /opt/kan/packages /opt/kan/apps -name 'tsconfig.json' -exec sed -i 's|"@kan/tsconfig/|"../../tooling/typescript/|g' {} +
$STD pnpm build --filter=@kan/web
cd /opt/kan/apps/api
$STD node build.mjs
unset NEXT_PUBLIC_USE_STANDALONE_OUTPUT CI
msg_ok "Built Application"
@@ -64,9 +95,10 @@ function update_script() {
$STD pnpm exec drizzle-kit migrate
msg_ok "Ran Database Migrations"
msg_info "Starting Service"
msg_info "Starting Services"
systemctl enable -q --now kan-api
systemctl start kan
msg_ok "Started Service"
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
exit
-2
View File
@@ -31,8 +31,6 @@ function update_script() {
exit
fi
ensure_dependencies cron
if check_for_gh_release "speedtest-tracker" "alexjustesen/speedtest-tracker"; then
PHP_VERSION="8.4" PHP_FPM="YES" setup_php
setup_composer
+28 -5
View File
@@ -34,9 +34,11 @@ BETTER_AUTH_TRUSTED_ORIGINS=http://${LOCAL_IP}:3000
POSTGRES_URL=postgres://${PG_DB_USER}:${PG_DB_PASS}@localhost:5432/${PG_DB_NAME}
NEXT_PUBLIC_ALLOW_CREDENTIALS=true
TRELLO_APP_API_KEY=
TRELLO_APP_API_SECRET=
TRELLO_APP_SECRET=
HOSTNAME=0.0.0.0
PORT=3000
API_PORT=4000
KAN_API_URL=http://127.0.0.1:4000
NODE_ENV=production
EOF
msg_ok "Configured Application"
@@ -49,6 +51,8 @@ $STD pnpm install --ignore-scripts --prod=false
export CI=true
find /opt/kan/packages /opt/kan/apps -name 'tsconfig.json' -exec sed -i 's|"@kan/tsconfig/|"../../tooling/typescript/|g' {} +
$STD pnpm build --filter=@kan/web
cd /opt/kan/apps/api
$STD node build.mjs
unset NEXT_PUBLIC_USE_STANDALONE_OUTPUT CI
msg_ok "Built Application"
@@ -63,12 +67,31 @@ cd /opt/kan/packages/db
POSTGRES_URL="postgres://${PG_DB_USER}:${PG_DB_PASS}@localhost:5432/${PG_DB_NAME}" $STD pnpm exec drizzle-kit migrate
msg_ok "Ran Database Migrations"
msg_info "Creating Service"
msg_info "Creating Services"
cat <<EOF >/etc/systemd/system/kan-api.service
[Unit]
Description=Kan API
After=network.target postgresql.service
Requires=postgresql.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/kan/apps/api/dist
EnvironmentFile=/opt/kan/.env
ExecStart=/usr/bin/node main.mjs
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/kan.service
[Unit]
Description=Kan Board
After=network.target postgresql.service
After=network.target postgresql.service kan-api.service
Requires=postgresql.service
Wants=kan-api.service
[Service]
Type=simple
@@ -82,8 +105,8 @@ RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now kan
msg_ok "Created Service"
systemctl enable -q --now kan-api kan
msg_ok "Created Services"
motd_ssh
customize
-1
View File
@@ -15,7 +15,6 @@ update_os
msg_info "Installing Dependencies"
$STD apt install -y \
cron \
nginx \
sqlite3
setcap cap_net_raw+ep /bin/ping