[Unit] Description=sidekiq for <%= "#{fetch(:application)} (#{fetch(:stage)})" %> After=syslog.target network.target [Service] Type=simple Environment=RAILS_ENV=<%= fetch(:rails_env) %> WorkingDirectory=<%= fetch(:deploy_to) %>/current ExecStart=<%= sidekiq_cmd %> <%= process_options(index) %> ExecReload=/bin/kill -TSTP $MAINPID ExecStop=/bin/kill -TERM $MAINPID <%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %> <%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) %> <%="User=#{sidekiq_user(role)}" if sidekiq_user(role) %> <%= "MemoryAccounting=#{ !!max_mem(index) }" if max_mem(index) %> <%= "MemoryLimit=#{ max_mem(index) }" if max_mem(index) %> # Greatly reduce Ruby memory fragmentation and heap usage # https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/ Environment=MALLOC_ARENA_MAX=2 RestartSec=1 Restart=on-failure SyslogIdentifier=sidekiq [Install] WantedBy=default.target