PERFORMANCE TESTING
=========================================
//all-purpose lookup
curl -w '\nLookup time:\t%{time_namelookup}\nConnect
time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer
time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null
http://ethniodev.com/remotes/17436
//Check the number of apache clients:
pgrep -c httpd
// Check memory:
free -m
(the cached amount should be at least 500, its measured in MB)
// Benchmark (best done from the local machine)
ab -n 5000 -c 50 http://ethnio.com/remotes/30090
(reqs. per second should be like 800 or something big like that)
MISC CLI
=========================================
// copy into every subdir
find -type d -exec cp /robots.txt {} \;
find -name "robots.txt" -exec rm {} \;
STARTING MYSQL FORM CLI (ON OSX)
=========================================
sudo /usr/local/mysql/bin/mysqld_safe
TEXTDRIVE
=========================================
https://webmin.alberni.textdrive.com/
ethnio
eT
HURRICANE ELECTRIC
=========================================
https://admin.he.net/
SUBVERSION
=========================================
svn co http://ethnio.textdriven.com/svn/ethnio/trunk .
svn copy http://ethnio.textdriven.com/svn/ethnio/branches/filter-stable
http://ethnio.textdriven.com/svn/ethnio/tags/filters-stable-latest
// creating a tag
svn copy http://ethnio.textdriven.com/svn/ethnio/trunk
http://ethnio.textdriven.com/svn/ethnio/tags/latest-stable
//Adding a new subversion user
1. cd to the domain’s etc/ directory
2. with any text editor, edit ‘svn-access.conf’ by adding a ‘permission
line’ for ‘newuser’ to an existing repository (repositories are created
in webmin
3. add a password for ‘newuser’ to the svn.basic.passwd file with
bash$ htpasswd svn.basic.passwd newuser
// (it will prompt twice for the new password)
// Editing an existing user’s password
1. cd to the domain’s etc/ directory
2. edit the user’s password with
bash$ htpasswd svn.basic.passwd existinguser
(again, it will prompt twice)
// Editing an existing user’s permissions
1. cd to the domain’s etc/ directory
2. edit the existing user’s permission line in the correct repository in
‘svn-access.conf’ (with any text editor)
// Removing a user
1. cd to the domain’s etc/ directory
2. remove the user’s permission line from the ‘svn-access.conf’ file (with
any text editor)
3. remove the user’s password line from the ‘svn.basic.passwd’ file (with
any text editor)
TRAC
=========================================
#this aint right. I hate apache.
#RewriteEngine On
#RewriteRule ethnio(.*) http://ethnio.textdriven.com:9046/ethnio$1 [P]
AuthType Basic
AuthName "Ethnio"
AuthUserFile /users/home/ethnio/trac.htpasswd
Require valid-user
[ethnio@alberni ~/etc]$ htdigest trac.digest.passwd ethnio.textdriven.com chris
Adding user chris in realm ethnio.textdriven.com
New password:
Re-type new password:
[ethnio@alberni ~/etc]$ pwd
/users/home/ethnio/etc
http://manuals.textdrive.com/read/chapter/54
MOA
=========================================
moa
192.168.0.21
IMAGEMAGICK
=========================================
installing imagemagick
uninstall and reinstall everything
http://www.elctech.com/2007/2/24/installing-rmagick-properly-in-osx
had to uninstall and CLEAN libiconv:
sudo port -f uninstall libiconv && sudo port clean --all libiconv && sudo port
install libiconv
RAILS
=========================================
// using the logger in a controller
logger.debug(" ------------ #{params[:screener]}")
if params[:screener]
logger.debug(" ------------ #{params[:screener][:active]}")
end
logger.debug(" ------------ #{@screener.active}")
SVN
=========================================
property seting
$ svn propset svn:ignore "*" public/assets
$ svn propset svn:ignore "assets" public
$ svn ci public
Compare two remote builds:
svn diff
http://ethnio.textdriven.com/svn/ethnio/tags/filters-stable-caching-fix2
http://ethnio.textdriven.com/svn/ethnio/branches/filters-stable
Create a tag
cd /working/dir
svn copy . http://ethnio.textdriven.com/svn/ethnio/tags/TAGNAME
Create a branch
cd /working/dir
svn copy . http://ethnio.textdriven.com/svn/ethnio/branches/BRANCHNAME
(you can add -r right after copy to specify a revision.)
CAP
=========================================
cap demo deploy -S head=true
to run a command on the macghine
cap demo invoke command="ls" -S tag=whatever
CERTS
=========================================
openssl genrsa -out www.mycompany.com.key 2048
openssl req -new -x509 -key ethnio.textdriven.com.key -out
ethnio.textdriven.com.cr
DEPLOYING
=========================================
1978.......w!
cap production deploy -S head=true
https://72.249.12.124:10000/
Dont use head! use tag=tagname
SPECS
=========================================
Current specs:
Apache 2.2
4 instances of Mongrel 1.0 (but 1.3 is out and fixes mongrel_restart bug. we
should upgrade soon)
ruby 1.8.6
rails 2.02
mysql 5.0.22
apache 2.2. installation configuration:
./configure --prefix=/usr/local/apache2 --enable-mods-shared=all \
--enable-deflate --enable-proxy --enable-proxy-balancer \
--enable-proxy-http --enable-ssl --with-axps2
RESTARTING MONGREL
===============================
sudo /etc/init.d/mongrel_cluster stop && sudo /etc/init.d/mongrel_cluster start
or (not sure which is better)
mongrel_rails cluster::start -C config/mongrel/production/mongrel_cluster.yml
DEPLOYING
===============================
#always deploy from a tag, look up the last (automatically created) tag in trac
cap production deploy -S tag=********
#Tags look like this: ethnio-20080105023744-ci and you can find them by clicking
on browse source in trac
Turning off Traffic Politely
===============================
# => puts the maintenance page in place, apache sends it all traffic
# note that head=true isnt used in this case, just needs to be there.
cap production deploy:web:disable -S head=true
#To turn it back on
cap production deploy:web:enable -S head=true
# => removes the banner
Restarting the application.
================================
# from your development machine
cap production deploy:restart -S tag=*******
Tailing the production log
===============================
sudo tail -f /usr/local/apache2/logs/ethnio_production.log
#always use the
sudo /etc/init.d/apache2 stop && sudo /etc/init.d/apache2 start
# for apache2.2, which is what were running.
#DO NOT USE apache2ctl reload (thats the wrong version)
// editing the apache cong
sudo vi /usr/local/apache2/conf/httpd.conf
Public Private Keypairs
===============================
#create a key and dont use a password
ssh-keygen -t rsa
#scp it to the machine
scp .ssh/id_rsa.pub ethnio@ethniodev.com:.ssh/authorized_keys2
#BUT IN THIS CASE actually that last line will overwrite my key, instead just
cat ssh/id_rsa.pub and paste the output into .ssh/authorized_keys2 on
ethniodev.com thanks.
#add this to bash profile
alias ethnio='ssh ethnio@ethniodev.com'
LOGS
==============================
the big ones are in
/usr/local/apache2/logs
and in
/u/apps/ethnio/shared/log
(though that one can be pretty skimpy if we have the log config set to warn)
Also, some shortcuts:
watchethnio gives you tail -f on the production log
watchapache gives you the apache production log
watcherrors gives you the apache errors log.
SELENIUM
================================
to run selenium tests locally
ruby test/selenium/selenium_suite.rb
if your server is not started rake selenium:start_servant
When you are getting 500 errors
run rake selenium:server
(so that you can see the output)
look at /log/test.log and log/selenum.log
You might need to
rake db:setup
to apply migrations to the test db.
PROFILER
================================
script/performance/profiler 'Screener.find_by_id(1).filtered_recruits'
BENCHMARKER
================================
Make sure you first set the environment var.
export RAILS_PERF_DATA=/path/to/ethnio's/log/directory
railsbench perf_run 10
runs everything.
railsbench perf_run 10 -bm=remotes.edit --log
edit
/config/benchmarks.rb
/config/benchmarks.yml
PISTON
=================================
creates a local modifiable/updateable copy of a plugin.
piston import svn://adress /vendor/plugins/pluginname
MYSQL USER SETUP
=================================
mysql -uroot -p
<enter_mysql_root_pass>
CREATE DATABASE <DB_NAME>;
GRANT
ALL PRIVILEGES ON <DB_NAME>.* TO 'my_user'@'localhost' IDENTIFIED BY
'my_password' WITH GRANT OPTION;
replace localhost with % for all domains.
MYSQL CACHING
================================
set query caching in my.cnf
-- need to add instructions for that
then see if it is working:
show status like 'qc%'
MISC SHELL HACKERY
=================================
kill all except grep:
ps aux | grep selenium | sed /grep/d | awk {'print $2'} | xargs kill
PORT FORWARDING
=================================
ssh -L 9999:127.0.0.1:5900 -L 9998:127.0.0.1:548 -p123
ethnio@pedro.redirectme.net
just deduce it.