From 817b0ea517155056320558d25e5965b4f4d8b7d9 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:50:37 +0100 Subject: [PATCH] Split Discourse services; update SimpleLogin setup Add DISCOURSE_PUMA_BIND to Discourse env and switch the discourse.service to load EnvironmentFile=/opt/discourse/.env. Create a separate systemd unit for Sidekiq (discourse-sidekiq.service), enable both services, and adjust messaging to "Services". In simplelogin install: remove git from apt list, bump PostgreSQL setup from 16 to 17, and export FLASK_APP=server before running migrations/initialization so Flask commands run with the correct app context. --- install/discourse-install.sh | 28 ++++++++++++++++++++++++---- install/simplelogin-install.sh | 4 ++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/install/discourse-install.sh b/install/discourse-install.sh index 08f5c6613..44e89599a 100644 --- a/install/discourse-install.sh +++ b/install/discourse-install.sh @@ -60,6 +60,7 @@ DISCOURSE_SMTP_ADDRESS=localhost DISCOURSE_SMTP_PORT=25 DISCOURSE_SMTP_AUTHENTICATION=none DISCOURSE_NOTIFICATION_EMAIL=noreply@${LOCAL_IP} +DISCOURSE_PUMA_BIND=tcp://127.0.0.1:3000 EOF chown -R root:root /opt/discourse @@ -102,7 +103,7 @@ set +a $STD bundle exec rails assets:precompile msg_ok "Built Discourse Assets" -msg_info "Creating Service" +msg_info "Creating Services" cat </etc/systemd/system/discourse.service [Unit] Description=Discourse Forum @@ -112,7 +113,7 @@ After=network.target postgresql.service redis-server.service Type=simple User=root WorkingDirectory=/opt/discourse -Environment=RAILS_ENV=production +EnvironmentFile=/opt/discourse/.env Environment=PATH=/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ExecStart=/root/.rbenv/shims/bundle exec puma -w 2 Restart=on-failure @@ -121,8 +122,27 @@ RestartSec=5 [Install] WantedBy=multi-user.target EOF -systemctl enable -q --now discourse -msg_ok "Created Service" + +cat </etc/systemd/system/discourse-sidekiq.service +[Unit] +Description=Discourse Sidekiq +After=network.target postgresql.service redis-server.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/discourse +EnvironmentFile=/opt/discourse/.env +Environment=PATH=/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ExecStart=/root/.rbenv/shims/bundle exec sidekiq -q critical -q low -q default +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now discourse discourse-sidekiq +msg_ok "Created Services" msg_info "Configuring Nginx" cat </etc/nginx/sites-available/discourse diff --git a/install/simplelogin-install.sh b/install/simplelogin-install.sh index 15cca978f..fbe5c6821 100644 --- a/install/simplelogin-install.sh +++ b/install/simplelogin-install.sh @@ -23,7 +23,6 @@ $STD apt install -y \ libpq-dev \ cmake \ pkg-config \ - git \ redis-server \ nginx \ postfix \ @@ -31,7 +30,7 @@ $STD apt install -y \ opendkim-tools msg_ok "Installed Dependencies" -PG_VERSION="16" setup_postgresql +PG_VERSION="17" setup_postgresql APPLICATION="simplelogin" PG_DB_NAME="simplelogin" PG_DB_USER="simplelogin" setup_postgresql_db PYTHON_VERSION="3.12" setup_uv NODE_VERSION="22" setup_nodejs @@ -97,6 +96,7 @@ set -a # shellcheck source=/dev/null source /opt/simplelogin/.env set +a +export FLASK_APP=server $STD .venv/bin/flask db upgrade $STD .venv/bin/python init_app.py msg_ok "Configured SimpleLogin"