hokuto 0.0.1.8.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/hokuto +3 -0
- data/hokuto.gemspec +22 -0
- data/jars/jetty-ajp-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-annotations-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-client-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-continuation-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-deploy-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-http-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-io-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-jmx-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-jndi-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-overlay-deployer-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-plus-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-policy-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-rewrite-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-security-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-server-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-servlet-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-servlets-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-util-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-webapp-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-websocket-8.1.8.v20121106.jar +0 -0
- data/jars/jetty-xml-8.1.8.v20121106.jar +0 -0
- data/jars/servlet-api-3.0.jar +0 -0
- data/lib/hokuto.rb +14 -0
- data/lib/hokuto/application.rb +54 -0
- data/lib/hokuto/main.rb +69 -0
- data/lib/hokuto/runner.rb +4 -0
- data/lib/hokuto/server.rb +53 -0
- data/lib/hokuto/version.rb +3 -0
- metadata +102 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Naoto "Kevin" IMAI TOYODA
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Hokuto
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hokuto'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hokuto
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/hokuto
ADDED
data/hokuto.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hokuto/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "hokuto"
|
8
|
+
gem.version = Hokuto::VERSION
|
9
|
+
gem.authors = ["Kevin TOYODA"]
|
10
|
+
gem.email = ["condor1226@gmail.com"]
|
11
|
+
gem.description = %q{A lightweight application server for simple ruby web applications.}
|
12
|
+
gem.summary = <<-EOF
|
13
|
+
Hokuto: A lightweight web application server for simple ruby web applications depending on rack.
|
14
|
+
EOF
|
15
|
+
gem.homepage = "https://github.com/condor/hokuto"
|
16
|
+
gem.add_dependency 'jruby-rack'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/hokuto.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), '..', 'jars', '*.jar'))).each do |jar|
|
5
|
+
require jar
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'jruby-rack'
|
9
|
+
|
10
|
+
module Hokuto; end
|
11
|
+
|
12
|
+
require "hokuto/version"
|
13
|
+
require 'hokuto/server'
|
14
|
+
require 'hokuto/application'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require 'java'
|
4
|
+
require 'jruby-rack'
|
5
|
+
|
6
|
+
module Hokuto
|
7
|
+
class Application
|
8
|
+
|
9
|
+
java_import org.eclipse.jetty.webapp.WebAppContext
|
10
|
+
java_import org.jruby.rack.RackFilter
|
11
|
+
java_import javax.servlet.DispatcherType
|
12
|
+
java_import java.util.EnumSet
|
13
|
+
|
14
|
+
attr_reader :context, :context_root, :base_directory, :descriptor, :environment,
|
15
|
+
:min_instances, :max_instances
|
16
|
+
|
17
|
+
def initialize(args)
|
18
|
+
|
19
|
+
@context = WebAppContext.new
|
20
|
+
|
21
|
+
if args[:descriptor]
|
22
|
+
context.descriptor = args[:descriptor]
|
23
|
+
else
|
24
|
+
@environment = args[:environment]
|
25
|
+
@context_root = args[:context_root]
|
26
|
+
@base_directory = args[:base_directory]
|
27
|
+
@min_instances = args[:min_instances]
|
28
|
+
@max_instances = args[:max_instances]
|
29
|
+
|
30
|
+
setup_context
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def ==(other)
|
35
|
+
return false unless other.kind_of? Application
|
36
|
+
other.context_root == context_root
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def setup_context
|
41
|
+
# context configuration statically defined.
|
42
|
+
context.add_filter(RackFilter.java_class.name, '/*', java.util.EnumSet.allOf(javax.servlet.DispatcherType))
|
43
|
+
context.set_init_parameter('public.root', 'public')
|
44
|
+
context.add_event_listener(org.jruby.rack.RackServletContextListener.new)
|
45
|
+
|
46
|
+
# context configuration determined by given configuration parameters.
|
47
|
+
context.resource_base = base_directory
|
48
|
+
context.context_path = context_root
|
49
|
+
context.set_init_parameter('rack.env', environment)
|
50
|
+
context.set_init_parameter('jruby.min.runtimes', min_instances.to_s)
|
51
|
+
context.set_init_parameter('jruby.max.runtimes', max_instances.to_s)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/hokuto/main.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rack'
|
5
|
+
require 'java'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
require 'hokuto/server'
|
9
|
+
|
10
|
+
require 'optparse'
|
11
|
+
require 'yaml'
|
12
|
+
|
13
|
+
module Hokuto
|
14
|
+
module Main
|
15
|
+
|
16
|
+
def self.run(args)
|
17
|
+
config = parse_arguments(args)
|
18
|
+
|
19
|
+
if config_file = config.delete(:config_file)
|
20
|
+
config = YAML.load_file(config_file)
|
21
|
+
end
|
22
|
+
|
23
|
+
if config.include? :application
|
24
|
+
application_configs = [config.delete(:application)]
|
25
|
+
else
|
26
|
+
application_configs = config.delete(:applications)
|
27
|
+
end
|
28
|
+
|
29
|
+
server = Server.new(config)
|
30
|
+
application_configs.each do |application_config|
|
31
|
+
server.add Application.new(application_config)
|
32
|
+
end if application_configs
|
33
|
+
server.run
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.parse_arguments(args)
|
37
|
+
result = {
|
38
|
+
port: 7080,
|
39
|
+
}
|
40
|
+
app_config = {
|
41
|
+
environment: 'development',
|
42
|
+
context_root: '/',
|
43
|
+
base_directory: Dir.pwd,
|
44
|
+
min_instances: 1,
|
45
|
+
max_instances: 1
|
46
|
+
}
|
47
|
+
parser = OptionParser.new
|
48
|
+
parser.on('-f', '--config-file=CONFIG_FILE'){|v|app_config[:config_file] = YAML.load_file(v)}
|
49
|
+
parser.on('-w', '--web-xml=WEBXML'){|v|app_config[:descriptor] = v}
|
50
|
+
parser.on('-p', '--http-port=HTTP_PORT'){|v|result[:port] = v}
|
51
|
+
parser.on('-P', '--https-port=SECURE_PORT'){|v|result[:https_port] = v}
|
52
|
+
parser.on('-c', '--context-root=PATH'){|v|app_config[:context_root] = v}
|
53
|
+
parser.on('-d', '--base-directory=DIR'){|v|app_config[:base_directory] = v}
|
54
|
+
parser.on('-e', '--environment=DIR'){|v|app_config[:environment] = v}
|
55
|
+
parser.on('-s', '--min-instances=INSTANCES_ON_STARTUP'){|v|app_config[:min_instances] = v}
|
56
|
+
parser.on('-x', '--max-instances=MAXIMUM_INSTANCES'){|v|app_config[:max_instances] = v}
|
57
|
+
parser.parse!
|
58
|
+
|
59
|
+
app_config[:base_directory] ||= Dir.pwd
|
60
|
+
|
61
|
+
result.merge!(:application => app_config) unless app_config.empty?
|
62
|
+
result
|
63
|
+
end
|
64
|
+
|
65
|
+
class << self
|
66
|
+
private :parse_arguments
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
# represents the server process.
|
4
|
+
module Hokuto
|
5
|
+
class Server
|
6
|
+
|
7
|
+
java_import org.eclipse.jetty.server.handler.ContextHandlerCollection
|
8
|
+
java_import org.eclipse.jetty.server.nio.SelectChannelConnector
|
9
|
+
Jetty = org.eclipse.jetty.server.Server
|
10
|
+
|
11
|
+
attr_reader :http_port, :https_port
|
12
|
+
attr_reader :jetty, :applications, :handler_collection, :certs
|
13
|
+
|
14
|
+
# initialize the server.
|
15
|
+
#
|
16
|
+
def initialize(options = {})
|
17
|
+
@http_port = options[:port].to_i
|
18
|
+
@https_port = options[:https_port].to_i if options[:https_port]
|
19
|
+
@jetty = Jetty.new
|
20
|
+
@applications = {}
|
21
|
+
@handler_collection = ContextHandlerCollection.new
|
22
|
+
jetty.handler = @handler_collection
|
23
|
+
end
|
24
|
+
|
25
|
+
# register the application.
|
26
|
+
def add(application)
|
27
|
+
previous_application = applications.delete application.context_root
|
28
|
+
handler_collection.remove_handler previous_application.context if previous_application
|
29
|
+
|
30
|
+
handler_collection.add_handler application.context
|
31
|
+
applications[application.context_root] = application
|
32
|
+
end
|
33
|
+
|
34
|
+
# booting the server.
|
35
|
+
def run
|
36
|
+
[:INT, :TERM, :ABRT].each{|signal|Signal.trap(signal, ->{stop})}
|
37
|
+
|
38
|
+
connector = SelectChannelConnector.new
|
39
|
+
connector.port = http_port
|
40
|
+
connector.confidential_port = https_port if https_port
|
41
|
+
|
42
|
+
jetty.add_connector connector
|
43
|
+
jetty.start
|
44
|
+
|
45
|
+
jetty.join
|
46
|
+
end
|
47
|
+
|
48
|
+
# shutting down the server.
|
49
|
+
def stop
|
50
|
+
jetty.stop
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hokuto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.8.1.8
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kevin TOYODA
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jruby-rack
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: !binary |-
|
21
|
+
MA==
|
22
|
+
none: false
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: !binary |-
|
28
|
+
MA==
|
29
|
+
none: false
|
30
|
+
prerelease: false
|
31
|
+
type: :runtime
|
32
|
+
description: A lightweight application server for simple ruby web applications.
|
33
|
+
email:
|
34
|
+
- condor1226@gmail.com
|
35
|
+
executables:
|
36
|
+
- hokuto
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- .gitignore
|
41
|
+
- Gemfile
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- bin/hokuto
|
46
|
+
- hokuto.gemspec
|
47
|
+
- jars/jetty-ajp-8.1.8.v20121106.jar
|
48
|
+
- jars/jetty-annotations-8.1.8.v20121106.jar
|
49
|
+
- jars/jetty-client-8.1.8.v20121106.jar
|
50
|
+
- jars/jetty-continuation-8.1.8.v20121106.jar
|
51
|
+
- jars/jetty-deploy-8.1.8.v20121106.jar
|
52
|
+
- jars/jetty-http-8.1.8.v20121106.jar
|
53
|
+
- jars/jetty-io-8.1.8.v20121106.jar
|
54
|
+
- jars/jetty-jmx-8.1.8.v20121106.jar
|
55
|
+
- jars/jetty-jndi-8.1.8.v20121106.jar
|
56
|
+
- jars/jetty-overlay-deployer-8.1.8.v20121106.jar
|
57
|
+
- jars/jetty-plus-8.1.8.v20121106.jar
|
58
|
+
- jars/jetty-policy-8.1.8.v20121106.jar
|
59
|
+
- jars/jetty-rewrite-8.1.8.v20121106.jar
|
60
|
+
- jars/jetty-security-8.1.8.v20121106.jar
|
61
|
+
- jars/jetty-server-8.1.8.v20121106.jar
|
62
|
+
- jars/jetty-servlet-8.1.8.v20121106.jar
|
63
|
+
- jars/jetty-servlets-8.1.8.v20121106.jar
|
64
|
+
- jars/jetty-util-8.1.8.v20121106.jar
|
65
|
+
- jars/jetty-webapp-8.1.8.v20121106.jar
|
66
|
+
- jars/jetty-websocket-8.1.8.v20121106.jar
|
67
|
+
- jars/jetty-xml-8.1.8.v20121106.jar
|
68
|
+
- jars/servlet-api-3.0.jar
|
69
|
+
- lib/hokuto.rb
|
70
|
+
- lib/hokuto/application.rb
|
71
|
+
- lib/hokuto/main.rb
|
72
|
+
- lib/hokuto/runner.rb
|
73
|
+
- lib/hokuto/server.rb
|
74
|
+
- lib/hokuto/version.rb
|
75
|
+
homepage: https://github.com/condor/hokuto
|
76
|
+
licenses: []
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: !binary |-
|
86
|
+
MA==
|
87
|
+
none: false
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: !binary |-
|
93
|
+
MA==
|
94
|
+
none: false
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.24
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: ! 'Hokuto: A lightweight web application server for simple ruby web applications
|
101
|
+
depending on rack.'
|
102
|
+
test_files: []
|