2012-11-17 43 views
6

Tôi đang cố gắng thiết lập Monit cho Sidekiq. Dưới đây là những gì tôi có cho đến nay đối với tệp cấu hình của tôi:Monit Ruby on Rails Sidekiq

check process sidekiq_site 
    with pidfile /var/www/site/tmp/pids/sidekiq.pid 
    start program = "bundle exec sidekiq -C /var/www/site/config/sidekiq.yml -P /var/www/site/tmp/pids/sidekiq.pid" with timeout 90 seconds 
    if totalmem is greater than 200 MB for 2 cycles then restart # eating up memory? 
    group site_sidekiq 

Vấn đề là tôi nhận được thông báo khi tôi chạy lại nạp tiền mà chương trình "gói" không tồn tại.

Có ai có giải pháp cho việc này không?

+2

Cố gắng viết đường dẫn đầy đủ đến bundler, như '/usr/local/lib/ruby/gems/1.9/ đá quý/bundler-1.2.3/bin/bundle' hoặc thậm chí tiền tố mà đường dẫn với đường dẫn đến ruby. Sử dụng lệnh 'which bundle' để tìm đường dẫn đầy đủ. – taro

Trả lời

1

Dưới đây là một ý chính tôi đã viết trên github:

check process sidekiq_production with pidfile /var/run/sidekiq_production.pid 
     depends on redis-server 
     start program = "/etc/init.d/sidekiq_production start" with timeout 90 seconds 
     stop program = "/etc/init.d/sidekiq_production stop" with timeout 90 seconds 
     if totalmem is greater than 200 MB for 2 cycles then restart # eating up memory? 
     if 2 restarts within 3 cycles then timeout 

Tôi cũng đã viết một init script cho sidekiq trên Debian: https://gist.github.com/alain75007/5517948

4

Sau khi làm việc trên tôi monit và cấu hình sidekiq của riêng tôi, tôi có thể chia sẻ những gì làm việc cho tôi chạy ubuntu.

Trước tiên, có một tập lệnh khởi động sidekiq cho ubuntu nếu bạn đang ở trên bản phân phối đó. Có các kịch bản cho sidekiq và để quản lý công nhân: https://github.com/mperham/sidekiq/tree/master/examples/upstart/manage-one

Tôi gặp phải một vài lỗi với tập lệnh khởi động mặc định đó, vì tôi đang sử dụng rvm. Kiểm tra /var/logs/upstart/sidekiq-0.log làm sáng tỏ một số vấn đề. dòng này:

exec bin/sidekiq -i ${index} -e production -C config/sidekiq.yml -P tmp/pids/sidekiq-${index}.pid

cần phải được thay đổi để exec bundle exec sidekiq + các tùy chọn

Sau đó, để giữ cho mọi thứ phù hợp với RVM tôi cài đặt, tôi đã thay đổi như sau:

#source $HOME/.rvm/scripts/rvm 
source /usr/local/rvm/scripts/rvm 

Trong/etc/monit/monitrc I tham khảo các tập lệnh mới nổi và có:

# sidekiq 
check process sidekiq 
    with pidfile /var/www/apps/myapp/current/tmp/pids/sidekiq-0.pid 
    start program = "/usr/bin/sudo start sidekiq index=0" 
    stop program = "/usr/bin/sudo stop sidekiq index=0" 
    if totalmem is greater than 500 MB for 2 cycles then restart # eating up memory? 
    if 3 restarts within 5 cycles then timeout 
0

Vấn đề của bạn là gói lệnh bị thiếu. Tôi nghĩ bạn nên viết các tập tin monit cấu hình như thế:

check process sidekiq 
    with pidfile /srv/www/projects/myapp/shared/log/production.sidekiq.pid 
    start program = "/usr/bin/env /usr/bin/env HOME=/home/USER_NAME RACK_ENV=production RAILS_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /srv/www/rails/myapp/current; bundle exec sidekiq'" as uid USER_NAME 
    stop program = "/usr/bin/env /usr/bin/env HOME=/home/USER_NAME RACK_ENV=production RAILS_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd/
    group myapp_workers 

Nếu bạn bước vào thư mục ứng dụng và gọi bó Tôi nghĩ rằng nó hoạt động.

0

Đây là cấu hình hoạt động trên Ubuntu với RVM

check process sidekiq-th with pidfile /web/vcms/tmp/pids/sidekiq.pid 
    start program = "/home/dimon/.rvm/bin/rvm-shell -c '/web/vcms/sidekiq.sh start'" 
    stop program = "/bin/bash /web/vcms/sidekiq.sh stop &" 

Nó sử dụng một script, các đường chính là

bắt đầu

cd /web/vcms; sidekiq -d -e production & 

và dừng

sidekiqctl stop $PIDFILE 

Tôi không phải là một guru vỏ kịch bản và sẽ biết ơn vì lời khuyên nào =)

1

Cuối cùng giải pháp này làm việc cho tôi như quyến rũ :)

check process sidekiq with pidfile path_to_my_pid_file/sidekiq.pid 

start program = "/bin/bash -c 'cd my_app_current && source /home/myuser/.rvm/environments/[email protected] && bundle exec sidekiq -e production -P path_to_my_pid_file/sidekiq.pid -L /my_shared_folder_path/log/sidekiq.log -C my_app_current/config/sidekiq.yml --daemon'" as uid "myuser" and gid "myuser" 

stop program = "/bin/bash -c 'kill -s INT `cat path_to_my_pid_file/sidekiq.pid`'" as uid "myuser" and gid "myuser" 

** Giữ điểm trong tâm trí sau: **

  • Tôi đang sử dụng RVM để quản lý phiên bản Ruby, vui lòng kiểm tra với rbenv.
  • Ở đây bạn cần phải vượt qua vị trí toàn cầu của ruby ​​đường tôi đi ngang qua nó ở đây: - /home/myuser/.rvm/environments/[email protected]