2010年6月30日 星期三

rails 設定多個 smtp account 寄信

Using multiple SMTP accounts with Rails & ActionMailer

可利用此技巧, 達到多SMTP 寄信的目的

2010年6月24日 星期四

haproxy nginx passenger munin

step1: nginx need stub_status_module
compile with [--with-http_stub_status_module]

step2: install munin
sudo apt-get install munin munin-node

 
#/etc/munin/munin.conf
#This will tell munin to connect to munin-node at 127.0.0.1 on the same machine.
[foo.net]
address 127.0.0.1
use_node_name yes


#Edit the file /etc/munin/munin-node.conf and change # Which port to bind to set
host 127.0.0.1

#Make sure that this is present in the file

allow ^127\.0\.0\.1$



http://github.com/barttenbrinke/munin-plugins-rails
http://www.alfajango.com/blog/how-to-monitor-your-railspassenger-app-with-munin/
http://github.com/jnstq/munin-nginx-ubuntu

 
#haproxy setting
reqisetbe ^Host:\ munin.foo.net foomunin

#nginx config
server {
listen 6166;
server_name munin.foo.net;
root /home/foo/deploy/shared/directory/munin;
}


#/etc/munin/plugin-conf.d/munin-node
[foo_*]
env.log_file '/home/foo/app/production.log'
user foo
command /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby %c
env.graph_category Foo



2010年6月22日 星期二

rails ip 辨識國家

how-to-know-user-location-with-rails
github geoip
Super fast IP to lat/lng in Rails

下載點 http://geolite.maxmind.com/download/geoip/database/

haproxy rails ip

haproxy不能正確記錄客戶端的IP
關於 rails 的扔remote_ip
http://kkito.cn/index.php/blog/getArticle/102/rails%E4%B8%AD%E5%BA%94%E6%B3%A8%E6%84%8F%E5%8F%AF%E8%83%BD%E5%AE%A2%E6%88%B7%E7%AB%AFip%E5%9C%B0%E5%9D%80%E6%98%AF%E4%BC%AA%E8%A3%85%E7%9A%84

2010年6月21日 星期一

capistrano path rake fail

http://blog.zerobearing.com/2009/04/27/capistrano-rake-command-not-found/
http://stackoverflow.com/questions/588934/using-ruby-enterprise-edition-gems-are-not-installed-where-i-would-expect
http://forum.slicehost.com/comments.php?DiscussionID=3657
http://stackoverflow.com/questions/257616/sudo-changes-path-why
http://groups.google.com/group/emm-ruby/browse_thread/thread/d0c685bbd096823a#msg_effa7d6ad42c541c
http://www.f15ijp.com/2009/11/30/sudo-no-tty-present-and-no-askpass-program-specified/

/etc/ssh/sshd_config:

PermitUserEnvironment yes
/etc/init.d/sshd restart


~/.ssh/environment
PATH=/opt/ruby-enterprise-1.8.7-2010.02/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games


http://formatinternet.wordpress.com/2009/07/06/sudo-rake-command-not-found/
~/.bashrc
alias sudo='sudo env PATH=$PATH'


sudo ln -s `which rake` /usr/local/bin/

#sudo: no tty present and no askpass program specified error
the /etc/sudoers file.
#commend sudo visudo
Defaults visiblepw

2010年6月13日 星期日

delayed_job capistrano production fail

主要參考
http://railscasts.com/episodes/171-delayed-job
http://www.magnionlabs.com/2009/2/28/background-job-processing-in-rails-with-delayed_job

不知道哪邊弄錯了用capistrano deploy 想啟動delayed_job 卻好像都沒反應
後來終於看到 有script/delayed_job run的指令 這個動作才可以讓你看到你錯在哪, start 只會無聲無息

2010年6月3日 星期四

nginx passenger config

nginx, worker_processes, and passenger_max_pool_size
Production Rails Tuning with Passenger: PassengerMaxProcesses

 
worker_processes 4; <= Setting the number of Nginx workers to the number of CPU cores should be sufficient.

http {
passenger_max_pool_size 20; # memory 256M should be 2, 2G should be 30, max_pool 不要設太大, 不要讓它吃到swap, free -ml ; vmstat 2 都可以看到現在memory 的情況
passenger_max_instances_per_app 15; #每種ap 能用到最多的instance, 所以如果跑兩個app 就會再少一點

# PassengerPoolIdleTime
# Recommended to be avg time per page * 2
# In Google Analytics... (Avg time on site / Avg page views) * 2
# Default: 300
passenger_pool_idle_time 144

}


超小型web server 設定
How to save MUCH RAM when running rails (linode/slicehost) and mod_rails passenger