Saleh is talking about using a Daemon to get rails to talk to LDAP. The code for the LDAP deamon and the code to make it look like a model live here . LDAP를 할 얘기 살레 데몬 레일을 얻기 위해 사용하는 방법에 대한 이야기입니다. deamon는 LDAP에 대한 코드와 코드 모델처럼 보이게하려고 여기에 살고있다. I will add a bit of code here and there, but hopefully the presenter will upload the slides so I don’t have to retype everything. 내가 여기와 거기,하지만 바라건대 그래서 모든걸 다시 입력하지 않아도됩니다 슬라이드를 업로드 발표자 코드의 비트가 추가됩니다. There is some great code in this presentation. 이 프레 젠 테이션에서 멋진 코드입니다.
Daemons are a bit of a dark art. 데몬은 어두운 예술의 비트가없습니다.
#
def daemonize
Kernel.fork and Kernel.exit
Process.setsid
Kernel.fork and Kernel.exit
# system maintenance items so you don't hold up directory maintenance and so you don't have to deal with permissions
File.umask 0
Dir.chdir '/'
# you don't want to hold onto
ObjectSpace.each_object(IO) {|io| io.close rescue nil}
STIN.open('/dev/null')
end
def daemonize
Kernel.fork and Kernel.exit
Process.setsid
Kernel.fork and Kernel.exit
# system maintenance items so you don't hold up directory maintenance and so you don't have to deal with permissions
File.umask 0
Dir.chdir '/'
# you don't want to hold onto
ObjectSpace.each_object(IO) {|io| io.close rescue nil}
STIN.open('/dev/null')
end
or just use a gem 그냥 보석을 사용하거나
require daemons
Daemons.daemonize
loop { 루프 (
# or whatever #이든 뭐든
conn = accept conn 수용 =
} )
You can interact directly with your Rails environment. 직접 레일 환경과 상호 작용 할 수있다.
include environment file 환경 파일을 포함
Threads 스레드
ThreadsBase.allow_concurrency = true ThreadsBase.allow_concurrency = 사실
Or you will get a nasty error: 또는 심한 오류를 얻을 것이다 :
Mysql::Error: Lost connection to MySQL server during query: MySQL은 : : 오류 : 쿼리하는 동안 서버에 MySQL에 연결이 끊어지면 :
Start and Stop 시작 및 중지
use a unix init script that takes start/stop/restart 그렇게 다시 시작 / 중지 / 시작 걸리는 유닉스 스크립트를 사용하여 초기화
OSX got ride of init script Solaris is going to do the same. OSX에 동일한 일을 할거야 초기화 스크립트의 솔라리스를 타고있어. Use Launchd instead. Launchd 대신 사용했다. It uses xml. 그것은 XML을 사용합니다.
Make sure the process doesn't start twice so that it doesn't run over itself. 물론이 과정을 두 번 이상 실행되지 않습니다 그래서 그것 자체가 시작되지 않습니다.
Use a Pid File. a의 PID 파일을 사용합니다. This is how the daemon finds out its own id for stopping. 이 데몬을 막는 방법에 대한 자체 id를 알면됩니다. It is also how you keep a process from starting up twice 그것도 두 번이나부터 어떻게 프로세스를 계속합니다
Configuration Files 구성 파일
Talk to your process. 귀하의 과정에 대화. Configure with yml files. yml 파일을 구성합니다. Read it in with YAML.Load YAML.Load 함께 읽어라
Logging 로깅
Daemon doesn’t have standard IO. 데몬 표준 입출력이되지 않습니다. Log it. 그것에 로그온합니다. Do it with Logger.new. Logger.new로 해보세요. Set log levels etc. Use logging for debugging. 로그 수준을 설정 등 디버깅을위한 로깅을 사용합니다.
Security 보안
When the system boots all is root. 모든 시스템은 부츠 때 뿌리입니다. You don’t want your app running as root. 루트로 실행하면 애플 리케이션 싶지 않아요. Drop privileges as soon as you can so that you become a lesser user. 권한 드롭대로 그렇게하면 덜 사용자가 될 수있다.
def become_user( …. See the slides 데프 become_user (.... 슬라이드보기
Testing 테스트
Create a test suite. 테스트 스위트를 만듭니다. Testing a daemon is challenging. 데몬 테스트에 도전한다. Spawn the daemon before tests. 테스트를하기 전에 데몬 Spawn.
Mocking makes testing safer. 조롱 안전 테스트를합니다. See slides for code under slide Testing – Mocking makes this much safer. 슬라이드를 아래의 코드에 대한 시험 - 비웃음이 훨씬 더 안전하게 슬라이드를 참조하십시오.
This was a great talk with real code. 이건 진짜 코드와 함께 좋은 얘기를했다. We need more code. 우리는 더 많은 코드가 필요합니다.
Tag s : RailsConf07 · Ruby On Rails No Comments 태그 : RailsConf07 루비는 레일에 코멘트가없습니다












0 responses so far ↓ 0 응답을 지금까지 ↓
There are no comments yet. 없다는 의견이 아직없습니다.