- Tatsuhiro Ujihisa
- http://ujihisa.blogspot.com/
- 非同期とは?
- スレッド、プロセス
- プロセス生成
| # If your workers are inactive for a long period of time, they'll lose | |
| # their MySQL connection. | |
| # | |
| # This hack ensures we re-connect whenever a connection is | |
| # lost. Because, really. why not? | |
| # | |
| # Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
| # | |
| # From: | |
| # http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
| # No RubyGems | |
| $ time hub version | |
| git version 1.6.0 | |
| hub version 0.2.0 | |
| real 0m0.047s | |
| user 0m0.015s | |
| sys 0m0.028s | |
| # With RubyGems |
| #!/bin/sh | |
| set -u | |
| set -e | |
| # Example init script, this can be used with nginx, too, | |
| # since nginx and unicorn accept the same signals | |
| # Feel free to change any of the following variables for your app: | |
| APP_ROOT=/home/deploy/public_html/rm/current | |
| PID=$APP_ROOT/tmp/pids/unicorn.pid | |
| ENV=production |
| Ruby の fork, thread と EventMachine gem を使ったプログラムの例 | |
| EventMachine は、 select(2) だか epoll(2) だかを使って非同期処理をしてくれるライブラリ。 C++ で書かれててはやい。 | |
| EventMachine.start に host, port と、 EventMachine::Connection を継承したクラスか任意のモジュールを指定する。クラス名を与えるとそのクラスのインスタンスがリクエストを受ける毎に作られる。必要なメソッドをオーバーライドして実装する。モジュール名を与えると、 EventMachine::Connection に MixIn される。こちらもメソッドをオーバーライドしてやる。 | |
| fork は Kernel#fork と Process#fork がある。 Process はモジュールでインスタンス化しない。どう違うのかよくわからない。 fork do ... end という書き方もできて、子プロセス毎にブロック内を実行して終了するみたい。これはわかりやすい。 $$ が pid になってる。 | |
| Thread は例だけ書いてみたけど、順番に実行しちゃうだけだしぜんぜんわかってない。 |
| 落書きの報告書 Twitterばかりしてる俺 | |
| 超高速でビルドするけど 動かないVirtual Machine | |
| やさしくないJavaの本ページ破りたい | |
| Chromeの裏 2ちゃんを覗いて見つかれば逃げ場もない | |
| 座って固まり 目を伏せながら | |
| 心のひとつも解りあえないプログラムをにらむ | |
| そして仲間たちは今夜辞職の計画をたてる | |
| とにかくもう 会社や家には帰りたくない | |
| 自分の業務が何なのかさえ 解らず震えている | |
| 25の夜 |
| # Redis | |
| %w{6379}.each do |port| | |
| God.watch do |w| | |
| w.name = "redis" | |
| w.interval = 30.seconds | |
| w.start = "/etc/init.d/redis start" | |
| w.stop = "/etc/init.d/redis stop" | |
| w.restart = "/etc/init.d/redis restart" | |
| w.start_grace = 10.seconds | |
| w.restart_grace = 10.seconds |
| #!/bin/bash | |
| # | |
| # Startup script for the Supervisor server | |
| # | |
| # Tested with Red Hat Enterprise Linux Server release 5.5 | |
| # | |
| # chkconfig: 2345 85 15 | |
| # description: Supervisor is a client/server system that allows its users to \ | |
| # monitor and control a number of processes on UNIX-like \ | |
| # operating systems. |
| ■事前準備 | |
| # useradd -s /bin/false -d /usr/nginx nginx | |
| # yum -y install libevent-devel pcre-devel zlib-devel openssl-devel | |
| ■インストール | |
| # export NGINX=nginx-1.0.5 | |
| # wget http://www.nginx.org/download/"$NGINX".tar.gz | |
| # tar zxvf "$NGINX".tar.gz | |
| # cd $NGINX |
この文章は http://www.adobe.com/jp/joc/max2011/cyb/index.html (Adobe MAX 2011 : 上司の説得が必要な方へ)一般向けテンプレートが元ネタです。ネタを活かしきれていないですがご容赦を。(下記テンプレの文責はmakamakaに帰しますが、実際に使用した結果の責任は負いかねます)
#上司の説得が必要な方へ
「YAPC::Asia Tokyo 2011に参加したいが、上司が首を縦に激しく振ってくれない」という方のために、YAPC::Asiaに参加するメリットをアピールするための文章テンプレートを用意しました。ぜひ、カスタマイズしてご利用ください。っていうか、そのまま使うのはおやめください。