--- bp version 2 Wed May 28 00:13:43 +0000 2008 +++ bp version 4 Tue Aug 12 03:09:46 +0000 2008 @@ -1,386 +1,461 @@ -STARTING MYSQL FORM CLI (ON OSX) +============================ +# the ethnio admin cheat sheet; use it with cheat for optimal happiness: +http://errtheblog.com/posts/32-cheat-again +# version 3.0 by maintainer chris blow august 11, 2008 +# 919 763 5299 is my mothers phone number +# tell her if wrote something wrong and you are sore about it. +# otherwise please add yer notes and send it back to me! = + ============================ -========================================= -sudo /usr/local/mysql/bin/mysqld_safe +# NOTE: if you see a bug please file it here for now +# NOTE: if you fix a bug write it down +# NOTE: do not put passwords in this file -TEXTDRIVE -========================================= -https://webmin.alberni.textdrive.com/ -ethnio -eT + ============================================== + = BUGS & todos = + ============================================== -HURRICANE ELECTRIC -========================================= +BUG: filters break the recruits table. (Per-incident patch - login with mysql +and ------ update screeners set filters=NULL where remote_key =12345; ) +BUG: some js problems with reordering questions. Not reproducible reliably. (Per +incident patch: blame it on Mozilla or Microsoft) +BUG: mongrel_restart is broken. +BUG: +BUG: +BUG: ... add em please -https://admin.he.net/ +TODO: upgrade rails + 1.3 is out and fixes mongrel_restart bug. we should upgrade soon. Also might + fix caching extension bug. + +BUG FIXED 08/11: logrotate bug. Logs were not getting rotated correctly because +mongrel was not being restarted. + Also an unnecessary rake log:clear needed to be removed. Used copytruncate + instead. updated the logrotate section with what we are now using (correct per + rimuhost techs). +BUG FIXED 08/11: The last page of the screener displays as plaintext js. + This was being caused by apache not handling the POST to the remotes/12345 url + (which serves js with a GET using rails REST magic). the fix, in the + ethnio.conf: -SUBVERSION -========================================= + RewriteCond %{REQUEST_METHOD} POST + RewriteRule ^/(.*)$ balancer://ethnio_production_cluster%{REQUEST_URI} + [P,QSA,L] -svn co http://ethnio.textdriven.com/svn/ethnio/trunk . + =============================================== + = IN CASE OF EMERGENCY = + =============================================== +###### worst case scenario + # The worst thing that can happen is that ethnio is not down but it is not + serving files. + # That is, apache is up, but mongrel is down. + # You must either stop apache, or (much better) turn off traffic politely with + capistrano. -svn copy http://ethnio.textdriven.com/svn/ethnio/branches/filter-stable -http://ethnio.textdriven.com/svn/ethnio/tags/filters-stable-latest -// creating a tag +#TODO -svn copy http://ethnio.textdriven.com/svn/ethnio/trunk -http://ethnio.textdriven.com/svn/ethnio/tags/latest-stable + ==================================================== + = specs = + ==================================================== +current specs: +apache 2.2 +4 instances of mongrel 1.0 +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 -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 + ================================================= + = logrotate = + ================================================= -(it will prompt twice for the new password) +#### this is the latest logrotate using copytruncate instead of stupid +postrotate stuff + /u/apps/ethnio/shared/log/production.log { + weekly + missingok + rotate 8 + compress + notifempty + # postrotate + # cd /u/apps/ethnio/current&& rake log:clear + # endscript + copytruncate + } -Editing an existing user’s password -1. cd to the domain’s etc/ directory -2. edit the user’s password with + ============================================ + = Cruise Control and the CC box = + ============================================ -bash$ htpasswd svn.basic.passwd existinguser +#TODO -(again, it will prompt twice) -Editing an existing user’s permissions + ============================================ + = performance = + ============================================ -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 +########## all-purpose performance 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 -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) +########## check the number of apache clients: + pgrep -c httpd (should be well less than the max set in the relevant conf) +########## 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) +########## using profiler (easy but often unintelligible imo) + script/performance/profiler 'screener.find_by_id(1).filtered_recruits' -TRAC -========================================= +########## using benchmarker + # make sure you first set the environment var. + export rails_perf_data=/path/to/ethnio's/log/directory -#this aint right. I hate apache. -#RewriteEngine On -#RewriteRule ethnio(.*) http://ethnio.textdriven.com:9046/ethnio$1 [P] + #run everything + railsbench perf_run 10 -AuthType Basic -AuthName "Ethnio" -AuthUserFile /users/home/ethnio/trac.htpasswd -Require valid-user + #also see + railsbench perf_run 10 -bm=remotes.edit --log -[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 + #and edit + /config/benchmarks.rb + /config/benchmarks.yml -http://manuals.textdrive.com/read/chapter/54 + =============================================== + = subversion = + =============================================== +######### checkout + svn co http://ethnio.textdriven.com/svn/ethnio/trunk . +######### branching + svn copy http://ethnio.textdriven.com/svn/ethnio/branches/filter-stable + http://ethnio.textdriven.com/svn/ethnio/tags/filters-stable-latest -CLI -========================================= +########## tagging + svn copy http://ethnio.textdriven.com/svn/ethnio/trunk + http://ethnio.textdriven.com/svn/ethnio/tags/latest-stable -copy into every subdir +####### adding a new subversion user (gets fucked up a lot) + # 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 + htpasswd svn.basic.passwd newuser -find -type d -exec cp /robots.txt {} \; +####### editing an existing user’s password + # 1. cd to the domain’s etc/ directory + # 2. edit the user’s password with + htpasswd svn.basic.passwd existinguser -find -name "robots.txt" -exec rm {} \; +########## 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) -MOA -========================================= +######### 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) -moa -192.168.0.21 + ======================================= + = trac = + ======================================= -IMAGEMAGICK -========================================= +# TODO: As of August 2008 something is wrong with trac permissions and CGB cant +get in. CGB hasn't spent too much time on it and frequently takes the stupidly +lazy route of just taking down the .htaccess file when he needs to get in. +Emphasis on stupid. -installing imagemagick +########## totally useless fragmentary notes on this problem -uninstall and reinstall everything + #rewriteengine on + #rewriterule ethnio(.*) http://ethnio.textdriven.com:9046/ethnio$1 [p] -http://www.elctech.com/2007/2/24/installing-rmagick-properly-in-osx + 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 -had to uninstall and CLEAN libiconv: + http://manuals.textdrive.com/read/chapter/54 -sudo port -f uninstall libiconv && sudo port clean --all libiconv && sudo port -install libiconv + =========================================== + = imagemagick = + =========================================== +# TODO: we no longer use imagemagick for graphs, just for logo resizing, so that +should be changed to minimagick or a smaller lib. -RAILS -========================================= +###### installing imagemagick (is a bear.) + #uninstall and reinstall everything as per + #http://www.elctech.com/2007/2/24/installing-rmagick-properly-in-osx -using the logger in a controller + #might also need to uninstall and clean libiconv: + sudo port -f uninstall libiconv && sudo port clean --all libiconv && sudo + port install libiconv - logger.debug(" ------------ #{params[:screener]}") - if params[:screener] - logger.debug(" ------------ #{params[:screener][:active]}") - end - logger.debug(" ------------ #{@screener.active}") + ======================================= + = svn = + ======================================= -SVN -========================================= +##### property seting + svn propset svn:ignore "*" public/assets + svn propset svn:ignore "assets" public + svn ci public -property seting +#### 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 -$ svn propset svn:ignore "*" public/assets -$ svn propset svn:ignore "assets" public -$ svn ci public +##### 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. -Compare two remote builds: +================================================== += selenium = +================================================== -svn diff -http://ethnio.textdriven.com/svn/ethnio/tags/filters-stable-caching-fix2 -http://ethnio.textdriven.com/svn/ethnio/branches/filters-stable + # to run selenium tests locally + ruby test/selenium/selenium_suite.rb + # if your server is not started rake selenium:start_servant -Create a tag + # when you are getting 500 errors you just need to start the selenium server + rake selenium:server -cd /working/dir -svn copy . http://ethnio.textdriven.com/svn/ethnio/tags/TAGNAME + #look at /log/test.log and log/selenum.log and you very well might need to + rake db:setup -Create a branch + #to apply migrations to the test db. -cd /working/dir -svn copy . http://ethnio.textdriven.com/svn/ethnio/branches/BRANCHNAME +========================================================== += piston = +========================================================== +###### create a local modifiable/updateable copy of a plugin. + # you want to do this instead of just using svn externals + # everything in ethnio should be pistonized + # http://piston.rubyforge.org/ + + piston import svn:#address /vendor/plugins/pluginname -(you can add -r right after copy to specify a revision.) +========================================================== += textdrive = +========================================================== + https:#webmin.alberni.textdrive.com/ + ethnio + eT..... -CAP -========================================= +==================================================== += -------------------- rails -------------------- = +==================================================== -cap demo deploy -S head=true +####### rails debugging -to run a command on the macghine + # using the logger in a controller + logger.debug(" ------------ #{params[:screener]}") + if params[:screener] + logger.debug(" ------------ #{params[:screener][:active]}") + end + logger.debug(" ------------ #{@screener.active}") -cap demo invoke command="ls" -S tag=whatever +####### rails logs + # the important ones are in + # + # /usr/local/apache2/logs (apache) + # and in + # /u/apps/ethnio/shared/log (the rest of the rails stack) + # + # 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. -CERTS -========================================= +==================================================== += -------------------- mysql -------------------- = +==================================================== -openssl genrsa -out www.mycompany.com.key 2048 -openssl req -new -x509 -key ethnio.textdriven.com.key -out -ethnio.textdriven.com.cr +# starting mysql on osx +sudo /usr/local/mysql/bin/mysqld_safe +#starting on ethnio.com +/etc/init.d/mysql start -DEPLOYING -========================================= +#stopping +/etc/init.d/mysql stop +#loggin in +mysql -uroot -p 1978.......w! -cap production deploy -S head=true -https://72.249.12.124:10000/ +==================================================== += -------------------- mongrel -------------------- = +==================================================== -Dont use head! use tag=tagname +# start +mongrel_rails cluster::start -C +/u/apps/ethnio/current/config/mongrel/production/mongrel_cluster.yml -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 +#no sudo? CGB 08/08 -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 +# stop +mongrel_rails cluster::stop -C +/u/apps/ethnio/current/config/mongrel/production/mongrel_cluster.yml +#the old way (above seems to work better, but it's mongrel so im keeping these +handy) +sudo /etc/init.d/mongrel_cluster stop +sudo /etc/init.d/mongrel_cluster start -RESTARTING APACHE -=============================== -#always use the +==================================================== += -------------------- apache -------------------- = +==================================================== -sudo /etc/init.d/apache2 stop && sudo /etc/init.d/apache2 start +###### 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) + # 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 + +==================================================== += -------------------- misc CLI -------------------- = +==================================================== -RESTARTING MONGREL -=============================== +######## making up some self-signed certs + openssl genrsa -out www.mycompany.com.key 2048 + openssl req -new -x509 -key ethnio.textdriven.com.key -out + ethnio.textdriven.com.cr -sudo /etc/init.d/mongrel_cluster stop && sudo /etc/init.d/mongrel_cluster start +######### corey port forwarding insanity + # just deduce it: + ssh -l 9999:127.0.0.1:5900 -l 9998:127.0.0.1:548 -p123 + ethnio@pedro.redirectme.net -or (not sure which is better) +####### copy robots.txt into every subdir + # (be careful with find it will fuck your box up fast!) + find -type d -exec cp /robots.txt {} \; -mongrel_rails cluster::start -C config/mongrel/production/mongrel_cluster.yml +####### do remove a file everywhere. + find -name "robots.txt" -exec rm {} \; -DEPLOYING -=============================== -#always deploy from a tag, look up the last (automatically created) tag in trac +####### kill all procs containing 'selenium' (excepting grep): + ps aux | grep selenium | sed /grep/d | awk {'print $2'} | xargs kill -cap production deploy -S tag=******** -#Tags look like this: ethnio-20080105023744-ci and you can find them by clicking -on browse source in trac +######### public private keypairs +# read the entire recipe before you start cookin, son + #create a key and dont use a password + ssh-keygen -t rsa + #now scp that mother to the machine + scp .ssh/id_rsa.pub ethnio@ethniodev.com:.ssh/authorized_keys2 + #but in this case actually that last line will overwrite an existing key, + instead just cat ssh/id_rsa.pub and paste the output + into .ssh/authorized_keys2 on ethniodev.com thanks. -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. + #now good gracious me add this to bash profile for the joy + alias ethnio='ssh ethnio@ethniodev.com' -cap production deploy:web:disable -S head=true + ======================================= + = monitors = + ======================================= -#To turn it back on +CGB has written a few monitor and maint scripts that live in ~/monitors. Now you +know. -cap production deploy:web:enable -S head=true -# => removes the banner + ========================================= + = cron = + ========================================= +#the root crontab +sudo crontab -e -Restarting the application. -================================ -# from your development machine -cap production deploy:restart -S tag=******* +#system daily/weekly/monthly crons +ls /etc/cron/* -Tailing the production log -=============================== -sudo tail -f /usr/local/apache2/logs/ethnio_production.log +======================================= += cap = +======================================= -Editing the apache conf -================================ -sudo vi /usr/local/apache2/conf/httpd.conf +###### deploy head to demo + cap demo deploy -s head=true +###### handy-ass trick to run a command on the machine + cap demo invoke command="ls" -s tag=whatever -Public Private Keypairs -=============================== +######### deploying + cap production deploy -S head=true -#create a key and dont use a password -ssh-keygen -t rsa + #always deploy from a tag, look up the last (automatically created) tag in + Cruise Control, like so: + cap production deploy -S tag='ethnio-********-ci' -#scp it to the machine -scp .ssh/id_rsa.pub ethnio@ethniodev.com:.ssh/authorized_keys2 + #tags look like this: ethnio-20080105023744-ci and you can find them by + clicking on browse source in trac -#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. +######### 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. -#add this to bash profile -alias ethnio='ssh ethnio@ethniodev.com' + cap production deploy:web:disable -s head=true + cap production deploy:web:enable -s head=true -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. +####### restarting the application. +# from your development machine +cap production deploy:restart -s tag=*******
cheat sheets.
$ cheat bp( add new | see all )
- updated sheets

- readme
- rspec
- boyfriend
- girlfriend
- loose_weight
- nils
- administrateme
- okay
- bartleby
- xpath
- git
- sprintf
- shoulda
- nonsense
- lucene_query_syntax
Advertisement