Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby で Windows サービスを作る

y-okubo
June 02, 2016

Ruby で Windows サービスを作る

表参道.rb 1 周年 LT

y-okubo

June 02, 2016
Tweet

More Decks by y-okubo

Other Decks in Technology

Transcript

  1. αʔϏεॲཧ require 'win32/daemon' include Win32 class DemoDaemon < Daemon def

    service_init end def service_main(*_args) end def service_stop end DemoDaemon.mainloop // ແݶϧʔϓ end
  2. ͦͷଞ w TFSWJDF@QBVTF  w TFSWJDF@SFTVNF  w TFSWJDF@OFUCJOEBEE 

    w TFSWJDF@OFUCJOESFNPWF  w TFSWJDF@OFUCJOEFOBCMF  w TFSWJDF@OFUCJOEEJTBCMF
  3. αʔϏεొ࿥ Service.new( :service_name => SERVICE_NAME, :display_name => SERVICE_DISPLAYNAME, :description =>

    'Sample Ruby service', :binary_path_name => ‘/usr/bin/ruby demo_daemon.rb’ ) ͜ͷΑ͏ͳهड़Λͨ͠3VCZεΫϦϓτΛ࣮ߦ͢Δͱ 8JOEPXTʹαʔϏε͕ొ࿥͞ΕΔ
  4. ઃఆϑΝΠϧ <service> <id> BackpulseEngine </id> <name> BackpulseEngine </name> <description> BackpulseEngine

    </description> <env name="PATH" value="\Users\y-okubo\.rbenv\versions\2.2.2\bin; %PATH%;"/> <env name="BUNDLE_GEMFILE" value="Gemfile"/> <executable> ruby </executable> <arguments> &quot;\Users\y-okubo\.rbenv\versions\2.2.2\bin\bundle&quot; exec ruby src\engine_daemon.rb </arguments>