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:
@@ -60,6 +60,7 @@ DISCOURSE_SMTP_ADDRESS=localhost
|
|||||||
DISCOURSE_SMTP_PORT=25
|
DISCOURSE_SMTP_PORT=25
|
||||||
DISCOURSE_SMTP_AUTHENTICATION=none
|
DISCOURSE_SMTP_AUTHENTICATION=none
|
||||||
DISCOURSE_NOTIFICATION_EMAIL=noreply@${LOCAL_IP}
|
DISCOURSE_NOTIFICATION_EMAIL=noreply@${LOCAL_IP}
|
||||||
|
DISCOURSE_PUMA_BIND=tcp://127.0.0.1:3000
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chown -R root:root /opt/discourse
|
chown -R root:root /opt/discourse
|
||||||
@@ -102,7 +103,7 @@ set +a
|
|||||||
$STD bundle exec rails assets:precompile
|
$STD bundle exec rails assets:precompile
|
||||||
msg_ok "Built Discourse Assets"
|
msg_ok "Built Discourse Assets"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Services"
|
||||||
cat <<EOF >/etc/systemd/system/discourse.service
|
cat <<EOF >/etc/systemd/system/discourse.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Discourse Forum
|
Description=Discourse Forum
|
||||||
@@ -112,7 +113,7 @@ After=network.target postgresql.service redis-server.service
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/opt/discourse
|
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
|
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
|
ExecStart=/root/.rbenv/shims/bundle exec puma -w 2
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
@@ -121,8 +122,27 @@ RestartSec=5
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
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"
|
msg_info "Configuring Nginx"
|
||||||
cat <<EOF >/etc/nginx/sites-available/discourse
|
cat <<EOF >/etc/nginx/sites-available/discourse
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ $STD apt install -y \
|
|||||||
libpq-dev \
|
libpq-dev \
|
||||||
cmake \
|
cmake \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
git \
|
|
||||||
redis-server \
|
redis-server \
|
||||||
nginx \
|
nginx \
|
||||||
postfix \
|
postfix \
|
||||||
@@ -31,7 +30,7 @@ $STD apt install -y \
|
|||||||
opendkim-tools
|
opendkim-tools
|
||||||
msg_ok "Installed Dependencies"
|
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
|
APPLICATION="simplelogin" PG_DB_NAME="simplelogin" PG_DB_USER="simplelogin" setup_postgresql_db
|
||||||
PYTHON_VERSION="3.12" setup_uv
|
PYTHON_VERSION="3.12" setup_uv
|
||||||
NODE_VERSION="22" setup_nodejs
|
NODE_VERSION="22" setup_nodejs
|
||||||
@@ -97,6 +96,7 @@ set -a
|
|||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source /opt/simplelogin/.env
|
source /opt/simplelogin/.env
|
||||||
set +a
|
set +a
|
||||||
|
export FLASK_APP=server
|
||||||
$STD .venv/bin/flask db upgrade
|
$STD .venv/bin/flask db upgrade
|
||||||
$STD .venv/bin/python init_app.py
|
$STD .venv/bin/python init_app.py
|
||||||
msg_ok "Configured SimpleLogin"
|
msg_ok "Configured SimpleLogin"
|
||||||
|
|||||||
Reference in New Issue
Block a user