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.
This commit is contained in:
CanbiZ (MickLesk)
2026-03-16 17:50:37 +01:00
parent 9413782993
commit 817b0ea517
2 changed files with 26 additions and 6 deletions

View File

@@ -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 <<EOF >/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 <<EOF >/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 <<EOF >/etc/nginx/sites-available/discourse

View File

@@ -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"