Skip to content

Instantly share code, notes, and snippets.

@esnya
Last active August 28, 2016 08:04
Show Gist options
  • Select an option

  • Save esnya/b76167a41d9af2018942 to your computer and use it in GitHub Desktop.

Select an option

Save esnya/b76167a41d9af2018942 to your computer and use it in GitHub Desktop.
どどんとふWindowsローカルサーバー用スクリプト

これは何?

Windowsで簡単にどどんとふサーバーを作れるようにしようかと思ったもの。 VPN張るなりすれば簡単に遊べるかと。

必要なもの

準備

  1. 適当なフォルダを作ってそこに移動
  2. DodontoF.batDodontoF.rbを置く
  3. どどんとふ本体のDodontoF_WebSetを解凍
  4. usbremix2フォルダを作り、USBRumix2をその中に解凍

DodontoF.rbをいじれば場所は変えてもいい

ディレクトリ構成

DodontoF_WebSet
  public_html
  saveData
usbrumix2
  license
  reference
  ruby
    ruby2.1
  shell
  ReadMe.txt
  ...
DodontoF.bat
DodontoF.rb

起動

  1. DodontoF.batをダブルクリック
  2. http://IPアドレス:3000/DodontoF/を開く
@"%~dp0usbrumix2\ruby\2.1\i386-mingw32\bin\ruby.exe" "%~dp0DodontoF.rb"
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'webrick'
opts = {
:BindAddress => '0.0.0.0',
:DocumentRoot => File.expand_path(File.dirname(__FILE__)) + '/DodontoF_WebSet/public_html',
:CGIInterpreter => File.expand_path(File.dirname(__FILE__)) + '/usbrumix2/ruby/2.1/i386-mingw32/bin/ruby.exe',
:Port => '3000',
}
srv = WEBrick::HTTPServer.new(opts)
srv.mount('/DodontoF/DodontoFServer.rb', WEBrick::HTTPServlet::CGIHandler, opts[:DocumentRoot] + '/DodontoF/DodontoFServer.rb')
['INT', 'TERM'].each {|signal|
Signal.trap(signal) {
srv.shutdown
}
}
srv.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment