ChildrenofkoRn

sidekiq.service

Mar 6th, 2020
450
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # place file in /home/%user%/.config/systemd/user/sidekiq.service
  2. #
  3. # run w/o sudo:
  4. # attention "--user" is an option, not a username on the system!
  5. #
  6. # systemctl --user reenable sidekiq
  7. # systemctl --user daemon-reload
  8. # systemctl --user restart sidekiq
  9. #
  10. # check sidekiq is run:
  11. # systemctl --user status sidekiq
  12. # ps aux | grep [s]idekiq
  13. # http://deployserver/sidekiq/busy
  14. #
  15. # or run task capistrano from dev server
  16. # add lines in config/deploy.rb:
  17. # set :init_system, :systemd
  18. # set :service_unit_name, "sidekiq"
  19. # and run:
  20. # cap production sidekiq:restart
  21.  
  22. [Unit]
  23. Description=sidekiq
  24. After=syslog.target network.target redis-server.service
  25.  
  26. [Service]
  27. Type=simple
  28. WorkingDirectory=/home/deployer/project/current
  29. ExecStart=/home/deployer/.rvm/bin/rvm default do bundle exec sidekiq -e production -C /home/deployer/project/shared/config/sidekiq.yml
  30. # if need PID-file uncomment these two lines:
  31. # ExecStartPost=/bin/sh -c "/bin/systemctl --user show -p MainPID sidekiq 2>/dev/null | /usr/bin/cut -d= -f2 > /home/deployer/project/shared/tmp/pids/sidekiq.pid"
  32. # PIDFile=/home/deployer/project/shared/tmp/pids/sidekiq.pid
  33.  
  34. # use `systemctl reload sidekiq` to send the quiet signal to Sidekiq
  35. # at the start of your deploy process.
  36. ExecReload=/bin/kill -TSTP $MAINPID
  37.  
  38. # Greatly reduce Ruby memory fragmentation and heap usage
  39. # https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
  40. Environment=MALLOC_ARENA_MAX=2
  41.  
  42. # if we crash, restart
  43. RestartSec=3
  44. Restart=on-failure
  45.  
  46. # output goes to /var/log/syslog
  47. StandardOutput=syslog
  48. StandardError=syslog
  49. #
  50. # This will default to "bundler" if we don't specify it
  51. SyslogIdentifier=sidekiq
  52.  
  53. [Install]
  54. WantedBy=multi-user.target
RAW Paste Data