Fix broken DB migration, other small changes

This commit is contained in:
vhsdream 2024-11-29 17:46:35 -05:00
parent 91fa4090c5
commit 47def6a84e
2 changed files with 11 additions and 8 deletions

View File

@ -76,6 +76,9 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "${PREV_RELEASE}" ]]
cp -r /opt/hoarder/apps/web/.next/standalone/apps/web/server.js /opt/hoarder/apps/web
cd /opt/hoarder/apps/workers
pnpm install --frozen-lockfile &>/dev/null
export DATA_DIR=/opt/hoarder_data
cd /opt/hoarder/packages/db
pnpm migrate &>/dev/null
mv /opt/.env /opt/hoarder/.env
sed -i "s/SERVER_VERSION=${PREV_RELEASE}/SERVER_VERSION=${RELEASE}/" /opt/hoarder/.env
msg_ok "Updated ${APP} to v${RELEASE}"

View File

@ -75,12 +75,13 @@ cp -r /opt/hoarder/apps/web/.next/standalone/apps/web/server.js /opt/hoarder/app
cd /opt/hoarder/apps/workers
$STD pnpm install --frozen-lockfile
export DATA_DIR=/opt/hoarder_data
HOARDER_SECRET=$(openssl rand -base64 36 | cut -c1-24)
cat <<EOF >/opt/hoarder/.env
SERVER_VERSION=$RELEASE
NEXTAUTH_SECRET="$HOARDER_SECRET"
NEXTAUTH_URL="http://localhost:3000"
DATA_DIR="/opt/hoarder_data"
DATA_DIR="$DATA_DIR"
MEILI_ADDR="http://127.0.0.1:7700"
MEILI_MASTER_KEY="$MASTER_KEY"
BROWSER_WEB_URL="http://127.0.0.1:9222"
@ -89,10 +90,9 @@ echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed Hoarder"
msg_info "Running Database Migration"
mkdir -p /opt/hoarder_data
mkdir -p ${DATA_DIR}
cd /opt/hoarder/packages/db
$STD pnpm migrate
mv db.db /opt/hoarder_data
msg_ok "Database Migration Completed"
msg_info "Creating Services"
@ -112,8 +112,8 @@ EOF
cat <<EOF >/etc/systemd/system/hoarder-web.service
[Unit]
Description=Hoarder Web
Wants=network.target hoarder-workers.service meilisearch.service
After=network.target hoarder-workers.service meilisearch.service
Wants=network.target hoarder-workers.service
After=network.target hoarder-workers.service
[Service]
ExecStart=pnpm start
@ -142,8 +142,8 @@ EOF
cat <<EOF >/etc/systemd/system/hoarder-workers.service
[Unit]
Description=Hoarder Workers
Wants=network.target hoarder-browser.service
After=network.target hoarder-browser.service
Wants=network.target hoarder-browser.service meilisearch.service
After=network.target hoarder-browser.service meilisearch.service
[Service]
ExecStart=pnpm start:prod
@ -156,7 +156,7 @@ TimeoutStopSec=5
WantedBy=multi-user.target
EOF
systemctl -q enable --now meilisearch.service hoarder-web.service hoarder-browser.service hoarder-workers.service
systemctl -q enable --now meilisearch.service hoarder-browser.service hoarder-workers.service hoarder-web.service
msg_ok "Created Services"
motd_ssh