## Description This systemd unit is installed on every self-hosted Linux install (copied by `deployment/setup_18.04.sh` / `setup_20.04.sh`) as well as our own worker hosts, so the memory cap has to be correct across a wide range of box sizes. It is currently a fixed `MemoryMax=1.2G`, chosen when workers ran on 2GB hosts (#12915). On larger hosts that fixed cap sits at a high fraction of the limit under normal load, so transient spikes hit the hard limit and the worker is OOM-restarted more often than necessary (each restart drops the jobs in-flight at that instant). Switching to `MemoryMax=60%` makes the cap scale with the host's physical memory instead of being fixed: - 2GB host: 60% = 1.2G, identical to today (no regression for small installs) - 4GB host: 60% = ~2.4G, room to absorb spikes without a premature restart - larger hosts scale proportionally `MemoryHigh=infinity` is unchanged, so the worker is still never throttled by cgroup reclaim (kept intentionally since #12871 to avoid reclaim-induced worker stalls). Only the hard cap changes, and only its scaling. Fixes https://linear.app/chatwoot/issue/INF-100 ## Type of change - [x] Performance (non-breaking change which improves performance)
32 lines
978 B
Desktop File
32 lines
978 B
Desktop File
[Unit]
|
|
Requires=network.target
|
|
PartOf=chatwoot.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=chatwoot
|
|
WorkingDirectory=/home/chatwoot/chatwoot
|
|
|
|
ExecStart=/bin/bash -lc 'dotenv bundle exec sidekiq -C config/sidekiq.yml'
|
|
|
|
Restart=always
|
|
RestartSec=1
|
|
TimeoutStopSec=30
|
|
KillMode=mixed
|
|
StandardInput=null
|
|
SyslogIdentifier=%p
|
|
LimitNOFILE=65536
|
|
|
|
MemoryMax=60%
|
|
MemoryHigh=infinity
|
|
MemorySwapMax=0
|
|
OOMPolicy=stop
|
|
|
|
Environment="PATH=/home/chatwoot/.rvm/gems/ruby-3.4.4/bin:/home/chatwoot/.rvm/gems/ruby-3.4.4@global/bin:/home/chatwoot/.rvm/rubies/ruby-3.4.4/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin"
|
|
Environment="PORT=3000"
|
|
Environment="RAILS_ENV=production"
|
|
Environment="NODE_ENV=production"
|
|
Environment="RAILS_LOG_TO_STDOUT=true"
|
|
Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-3.4.4"
|
|
Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-3.4.4:/home/chatwoot/.rvm/gems/ruby-3.4.4@global"
|