fix(erpnext): run bench setup production as root, add nginx+supervisor

- bench setup production requires root (is_root check) - was failing as frappe user
- Add nginx and supervisor as apt dependencies for production setup
- Remove custom erpnext.service - bench manages gunicorn+workers via supervisor
- Port 8000 → 80 (nginx reverse proxy)
- Fix bench update in CT to run as frappe user with proper PATH
This commit is contained in:
CanbiZ (MickLesk)
2026-03-25 14:26:04 +01:00
parent 929e78f39b
commit 825a718a07
3 changed files with 7 additions and 25 deletions

View File

@@ -22,6 +22,8 @@ $STD apt install -y \
libffi-dev \
libssl-dev \
redis-server \
nginx \
supervisor \
xvfb \
libfontconfig1 \
libxrender1 \
@@ -79,29 +81,10 @@ $STD systemctl enable --now redis-server
msg_ok "Configured ERPNext"
msg_info "Setting up Production"
$STD sudo -u frappe bash -c 'export PATH="$HOME/.local/bin:$PATH"; cd /opt/frappe-bench && bench setup production frappe --yes'
$STD bash -c 'export PATH="/home/frappe/.local/bin:$PATH"; cd /opt/frappe-bench && bench setup production frappe --yes'
$STD systemctl enable --now supervisor
msg_ok "Set up Production"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/erpnext.service
[Unit]
Description=ERPNext (Frappe Bench)
After=network.target mariadb.service redis-server.service
[Service]
Type=simple
User=frappe
WorkingDirectory=/opt/frappe-bench
ExecStart=/opt/frappe-bench/env/bin/gunicorn --bind 0.0.0.0:8000 --workers 4 --timeout 120 frappe.app:application
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now erpnext
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc