This is far from a comprehensive list, and if you just follow this things won't work. This also assumes you have _some_ knowledge of how Postfix, Monit, Linux works.
Postfix
I accept and read mail somewhere else (not on the VPS that sends mail). For example, I may use Google to accept mail on the Internet, however, I don't connect my server to Google to send mail. Because of this, when postfix on my server tried to send mail to mydomain.com, it always something like "there is no user
mydestination = localhost.localdomain, localhost
Also, to use it, my Rails app's setting were like this:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => "www.theinksquad.com"
}
SilverRack and Sources
Installing the clean 8.04 on SilverRack, /etc/apt/sources.list is virtually empty. You need to add:
deb http://ubuntu.media.mit.edu/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.media.mit.edu/ubuntu/ hardy restricted main multiverse universe
deb http://ubuntu.media.mit.edu/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.media.mit.edu/ubuntu/ hardy-updates restricted main multiverse universe
deb http://security.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu/ hardy-security restricted main multiverse universe
Then "sudo apt-get update" after
Monit
The tutorial above didn't have any tutorial for Monit or God.rb. Install the dependencies first:
sudo apt-get install flex byacc bison -y
Then monit (Make sure this is the latest and greatest version):
wget http://mmonit.com/monit/dist/beta/monit-5.0_beta7.tar.gz
tar -xzvf monit-5.0_beta7.tar.gz && cd monit-5.0_beta7/ && sudo ./configure && sudo make && sudo make install && cd ../
sudo mkdir /etc/monit.d
Then make the monit file for Apache. This file basically tells monit what to watch out for, and how.
Sample /etc/monit.d/apache.monitrc
check process apache with pidfile /var/run/apache2.pid
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 20 for 8 cycles then alert
group yourappnamehere
Since I use workling, I also made a seperate file for it:
server$ sudo vi /etc/monit.d/workling.monitrc
and paste (do a "which ruby" to find out where ruby is and replace the /usr/bin/ruby if needed)
check process workling with pidfile /var/www/yourappname/shared/log/workling.pid
start program = "/bin/bash -c 'HOME=/var/www/yourappname/current RAILS_ENV=production /usr/bin/ruby /var/www/yourappname/current/script/workling_client start'"
stop program = "/bin/bash -c '/usr/bin/ruby /var/www/yourappname/current/script/workling_client stop'"
if totalmem is greater than 180.0 mb for 5 cycles then restart
if cpu is greater than 90% for 5 cycles then restart
if 20 restarts within 20 cycles then timeout
group yourappname
Then reload monit via "sudo monit reload".
Now monit needs to be told to start automatically when we startup and when/if it crashes, we'll use upstart (this is for Ubuntu only?)
server$ sudo vi /etc/event.d/service_monit
and paste (do a "which monit" to find out where monit is and replace the /usr/local/bin/monit if needed)
# This is an event.d (upstart) script to keep monit running# To install disable the old way of doing things:
#
# /etc/init.d/monit stop && update-rc.d -f monit remove
#
# then put this script here: /etc/event.d/monit
#
# You can manually start and stop monit like this:
#
# start monit
# stop monit
#
# Michael Hale (http://halethegeek.com)
start on startup
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on runlevel 0
stop on runlevel 6
exec /usr/local/bin/monit -Ic /etc/monit/monitrc
respawn
1 comment:
I don't know about anyone else, but when i restart my server without modifying or creating /etc/event.d/service_monit it bring monit up.
Post a Comment