Supervisor vs systemd

What is the benefits of using the default supervisor vs configuring bench for systemd via:

bench setup systemd

if you prefer systemd instead of supervisor then use it.

everywhere in community and docs supervisor is used.

My question was why frappe would add an extra dependency to use supervisor when it could simply use built-in systemd ?
Is there anything supervisor does that is not provided by systemd? Or is it frappe wanted to be agnostic of systemd?

supervisor is the default process manager since beginning. systemd was added later. Everywhere you’ll find supervisor is used because it was there since beginning.

2020 onwards I’m not using supervisor or systemd. I’m using containerized setup for development as well as production.

1 Like

so, how to use systemd instead of supervisor?

bench setup systemd

then what next?

To accomplish that, you must create and manage Systemd Unit Files. At the minimum, you’ll need 1 per component of ERPNext that must start automatically:

  • Gunicorn Web Server
  • 3 Redis databases
  • Scheduler
  • Background Workers
  • NodeJS Socket service

Here are a few articles about Systemd’s Units:

Below is an example I’m personally using, which demonstrates how to start the gunicorn web server.

You cannot just copy & paste it: your own Unit File will need different values. But hopefully this gives you an idea. You can compare this to the data in 'frappe-bench/Procfile'

[Unit]
Description="Frappe HTTP Web Server"
After=network.target erpnext_redis.target
Wants=erpnext_redis_cache.service
PartOf=erpnext_web.target

[Service]
User=erp_service
Group=erp_group
Environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8,FRAPPE_SITE=foo.bar.com
ExecStart=/erpnext/mybench/env/bin/gunicorn -b 127.0.0.1:8000 -w 9 -t 120 frappe.app:application --preload
Restart=always
WorkingDirectory=/erpnext/mybench/sites
StandardOutput=file:/erpnext/mybench/logs/web.log
StandardError=file:/erpnext/mybench/logs/web.error.log

[Install]
WantedBy=multi-user.target
4 Likes

Thank you Brian, I found a simple solution for this.

bench setup systemd
sudo cp config/systemd/* /usr/lib/systemd/system/
sudo systemctl enable frappe-bench.target #use your init folder in my example using "frappe-bench"
sudo systemctl start frappe-bench.target
4 Likes

Does it bring anything new to the table?

The production setup page is updated and it advices to use containerized setup.
image

I am not sure why it is recommended way?

1 Like