knjappserver 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/check_running.rb +71 -0
- data/bin/knjappserver_start.rb +50 -0
- data/knjappserver.gemspec +107 -0
- data/lib/conf/README +1 -0
- data/lib/conf/conf_example.rb +109 -0
- data/lib/conf/conf_vars_example.rb +3 -0
- data/lib/files/database_schema.rb +111 -0
- data/lib/files/run/README +1 -0
- data/lib/include/class_customio.rb +21 -0
- data/lib/include/class_erbhandler.rb +36 -0
- data/lib/include/class_httpresp.rb +91 -0
- data/lib/include/class_httpserver.rb +91 -0
- data/lib/include/class_httpsession.rb +350 -0
- data/lib/include/class_httpsession_knjengine.rb +189 -0
- data/lib/include/class_httpsession_mongrel.rb +75 -0
- data/lib/include/class_httpsession_webrick.rb +75 -0
- data/lib/include/class_knjappserver.rb +455 -0
- data/lib/include/class_knjappserver_cleaner.rb +109 -0
- data/lib/include/class_knjappserver_errors.rb +117 -0
- data/lib/include/class_knjappserver_logging.rb +272 -0
- data/lib/include/class_knjappserver_mailing.rb +97 -0
- data/lib/include/class_knjappserver_threadding.rb +87 -0
- data/lib/include/class_knjappserver_web.rb +23 -0
- data/lib/include/class_log.rb +81 -0
- data/lib/include/class_log_access.rb +103 -0
- data/lib/include/class_log_data.rb +42 -0
- data/lib/include/class_log_data_link.rb +16 -0
- data/lib/include/class_log_data_value.rb +34 -0
- data/lib/include/class_log_link.rb +51 -0
- data/lib/include/class_session.rb +43 -0
- data/lib/include/gettext_funcs.rb +10 -0
- data/lib/include/magic_methods.rb +59 -0
- data/lib/knjappserver.rb +1 -0
- data/lib/pages/logs_latest.rhtml +57 -0
- data/lib/pages/logs_show.rhtml +32 -0
- data/lib/pages/spec.rhtml +10 -0
- data/spec/knjappserver_spec.rb +110 -0
- data/spec/spec_helper.rb +12 -0
- metadata +188 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "knjrbfw", ">= 0.0.3"
|
7
|
+
gem "erubis"
|
8
|
+
gem "knjdbrevision", ">= 0.0.2"
|
9
|
+
|
10
|
+
# Add dependencies to develop your gem here.
|
11
|
+
# Include everything needed to run rake, tests, features, etc.
|
12
|
+
group :development do
|
13
|
+
gem "rspec", "~> 2.3.0"
|
14
|
+
gem "bundler", "~> 1.0.0"
|
15
|
+
gem "jeweler", "~> 1.6.3"
|
16
|
+
gem "rcov", ">= 0"
|
17
|
+
gem "sqlite3"
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
erubis (2.7.0)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.6.3)
|
8
|
+
bundler (~> 1.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
knjdbrevision (0.0.2)
|
12
|
+
knjrbfw
|
13
|
+
knjrbfw (0.0.3)
|
14
|
+
rake (0.9.2)
|
15
|
+
rcov (0.9.9)
|
16
|
+
rcov (0.9.9-java)
|
17
|
+
rspec (2.3.0)
|
18
|
+
rspec-core (~> 2.3.0)
|
19
|
+
rspec-expectations (~> 2.3.0)
|
20
|
+
rspec-mocks (~> 2.3.0)
|
21
|
+
rspec-core (2.3.1)
|
22
|
+
rspec-expectations (2.3.0)
|
23
|
+
diff-lcs (~> 1.1.2)
|
24
|
+
rspec-mocks (2.3.0)
|
25
|
+
sqlite3 (1.3.3)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
java
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.0.0)
|
33
|
+
erubis
|
34
|
+
jeweler (~> 1.6.3)
|
35
|
+
knjdbrevision (>= 0.0.2)
|
36
|
+
knjrbfw (>= 0.0.3)
|
37
|
+
rcov
|
38
|
+
rspec (~> 2.3.0)
|
39
|
+
sqlite3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Kasper Johansen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= knjappserver
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to knjappserver
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Kasper Johansen. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "knjappserver"
|
18
|
+
gem.homepage = "http://github.com/kaspernj/knjappserver"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A multi-threadded app-web-server.}
|
21
|
+
gem.description = %Q{Which supports a lot of undocumented stuff.}
|
22
|
+
gem.email = "k@spernj.org"
|
23
|
+
gem.authors = ["Kasper Johansen"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "knjappserver #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.6
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby1.9.1
|
2
|
+
|
3
|
+
# This script checks if the knjappserver is running - if not it forks and start it.
|
4
|
+
require "rubygems"
|
5
|
+
require "optparse"
|
6
|
+
Dir.chdir("#{File.dirname(__FILE__)}/../")
|
7
|
+
|
8
|
+
begin
|
9
|
+
options = {
|
10
|
+
:command => "ruby knjappserver_start.rb",
|
11
|
+
:title => "knjappserver",
|
12
|
+
:forking => true
|
13
|
+
}
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: knjappserver.rb [options]"
|
16
|
+
|
17
|
+
opts.on("--command=[cmd]", "Run verbosely.") do |cmd|
|
18
|
+
options[:command] = cmd
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("--title=[title]", "The title of the appserver that should be checked for.") do |title|
|
22
|
+
options[:title] = title
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("--forking=[forkval]", "If you want the script to fork or not.") do |forking|
|
26
|
+
if forking.to_i >= 1
|
27
|
+
options[:forking] = true
|
28
|
+
else
|
29
|
+
options[:forking] = false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("--knjrbfw_path=[path]") do |path|
|
34
|
+
options[:knjrbfw_path] = path
|
35
|
+
end
|
36
|
+
end.parse!
|
37
|
+
rescue OptionParser::InvalidOption => e
|
38
|
+
print "#{e.message}\n"
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
if !options[:title]
|
43
|
+
print "No title was given.\n"
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
if !options[:command]
|
48
|
+
print "No command to execute was given.\n"
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
require "#{options[:knjrbfw_path]}knjrbfw"
|
53
|
+
require "knj/autoload"
|
54
|
+
require "tmpdir"
|
55
|
+
|
56
|
+
tmpdir = "#{Dir.tmpdir}/knjappserver"
|
57
|
+
tmppath = "#{tmpdir}/run_#{options[:title]}"
|
58
|
+
count = 0
|
59
|
+
|
60
|
+
if File.exists?(tmppath)
|
61
|
+
pid = File.read(tmppath)
|
62
|
+
count = Knj::Unix_proc.list("pids" => [pid]).length
|
63
|
+
end
|
64
|
+
|
65
|
+
exit if count > 0
|
66
|
+
|
67
|
+
if options[:forking]
|
68
|
+
exec(options[:command]) if fork.nil?
|
69
|
+
else
|
70
|
+
exec(options[:command])
|
71
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "#{File.dirname(__FILE__)}/../lib/knjappserver.rb"
|
4
|
+
require "knjrbfw"
|
5
|
+
|
6
|
+
ARGV.each do |arg|
|
7
|
+
if arg == "--active_support"
|
8
|
+
ARGV.delete(arg)
|
9
|
+
require "active_support"
|
10
|
+
require "active_support/core_ext"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
filepath = File.dirname(__FILE__) + "/../lib/"
|
15
|
+
|
16
|
+
if File.exists?($0)
|
17
|
+
conf_path = File.dirname($0) + "/../"
|
18
|
+
else
|
19
|
+
conf_path = File.dirname(__FILE__) + "/../"
|
20
|
+
end
|
21
|
+
|
22
|
+
require "#{conf_path}conf/conf_vars"
|
23
|
+
require "webrick"
|
24
|
+
require "#{$knjappserver_config["knjrbfw"]}knj/autoload"
|
25
|
+
require "#{$knjappserver_config["knjrbfw"]}knj/ext/webrick"
|
26
|
+
|
27
|
+
$knjappserver = {
|
28
|
+
:path => Knj::Php.realpath(File.dirname(__FILE__))
|
29
|
+
}
|
30
|
+
|
31
|
+
Knj::Os.chdir_file(Knj::Php.realpath(__FILE__))
|
32
|
+
require "#{filepath}include/class_knjappserver.rb"
|
33
|
+
|
34
|
+
#Lets hack the $stdout to make it possible to have many running threads that all uses print.
|
35
|
+
require "#{filepath}include/class_customio.rb"
|
36
|
+
cio = Knjappserver::CustomIO.new
|
37
|
+
$stdout = cio
|
38
|
+
|
39
|
+
Thread.new do
|
40
|
+
loop do
|
41
|
+
sleep 30
|
42
|
+
GC.enable if RUBY_ENGINE != "jruby"
|
43
|
+
GC.enable
|
44
|
+
GC.start
|
45
|
+
ObjectSpace.garbage_collect
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
print "Starting knjAppServer.\n"
|
50
|
+
require "#{conf_path}conf/conf"
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{knjappserver}
|
8
|
+
s.version = "0.0.6"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kasper Johansen"]
|
12
|
+
s.date = %q{2011-08-03}
|
13
|
+
s.description = %q{Which supports a lot of undocumented stuff.}
|
14
|
+
s.email = %q{k@spernj.org}
|
15
|
+
s.executables = ["check_running.rb", "knjappserver_start.rb"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/check_running.rb",
|
30
|
+
"bin/knjappserver_start.rb",
|
31
|
+
"knjappserver.gemspec",
|
32
|
+
"lib/conf/README",
|
33
|
+
"lib/conf/conf_example.rb",
|
34
|
+
"lib/conf/conf_vars_example.rb",
|
35
|
+
"lib/files/database_schema.rb",
|
36
|
+
"lib/files/run/README",
|
37
|
+
"lib/include/class_customio.rb",
|
38
|
+
"lib/include/class_erbhandler.rb",
|
39
|
+
"lib/include/class_httpresp.rb",
|
40
|
+
"lib/include/class_httpserver.rb",
|
41
|
+
"lib/include/class_httpsession.rb",
|
42
|
+
"lib/include/class_httpsession_knjengine.rb",
|
43
|
+
"lib/include/class_httpsession_mongrel.rb",
|
44
|
+
"lib/include/class_httpsession_webrick.rb",
|
45
|
+
"lib/include/class_knjappserver.rb",
|
46
|
+
"lib/include/class_knjappserver_cleaner.rb",
|
47
|
+
"lib/include/class_knjappserver_errors.rb",
|
48
|
+
"lib/include/class_knjappserver_logging.rb",
|
49
|
+
"lib/include/class_knjappserver_mailing.rb",
|
50
|
+
"lib/include/class_knjappserver_threadding.rb",
|
51
|
+
"lib/include/class_knjappserver_web.rb",
|
52
|
+
"lib/include/class_log.rb",
|
53
|
+
"lib/include/class_log_access.rb",
|
54
|
+
"lib/include/class_log_data.rb",
|
55
|
+
"lib/include/class_log_data_link.rb",
|
56
|
+
"lib/include/class_log_data_value.rb",
|
57
|
+
"lib/include/class_log_link.rb",
|
58
|
+
"lib/include/class_session.rb",
|
59
|
+
"lib/include/gettext_funcs.rb",
|
60
|
+
"lib/include/magic_methods.rb",
|
61
|
+
"lib/knjappserver.rb",
|
62
|
+
"lib/pages/logs_latest.rhtml",
|
63
|
+
"lib/pages/logs_show.rhtml",
|
64
|
+
"lib/pages/spec.rhtml",
|
65
|
+
"spec/knjappserver_spec.rb",
|
66
|
+
"spec/spec_helper.rb"
|
67
|
+
]
|
68
|
+
s.homepage = %q{http://github.com/kaspernj/knjappserver}
|
69
|
+
s.licenses = ["MIT"]
|
70
|
+
s.require_paths = ["lib"]
|
71
|
+
s.rubygems_version = %q{1.6.2}
|
72
|
+
s.summary = %q{A multi-threadded app-web-server.}
|
73
|
+
|
74
|
+
if s.respond_to? :specification_version then
|
75
|
+
s.specification_version = 3
|
76
|
+
|
77
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
78
|
+
s.add_runtime_dependency(%q<knjrbfw>, [">= 0.0.3"])
|
79
|
+
s.add_runtime_dependency(%q<erubis>, [">= 0"])
|
80
|
+
s.add_runtime_dependency(%q<knjdbrevision>, [">= 0.0.2"])
|
81
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
82
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
83
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
|
84
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
85
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
86
|
+
else
|
87
|
+
s.add_dependency(%q<knjrbfw>, [">= 0.0.3"])
|
88
|
+
s.add_dependency(%q<erubis>, [">= 0"])
|
89
|
+
s.add_dependency(%q<knjdbrevision>, [">= 0.0.2"])
|
90
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
91
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
92
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
|
93
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
94
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
95
|
+
end
|
96
|
+
else
|
97
|
+
s.add_dependency(%q<knjrbfw>, [">= 0.0.3"])
|
98
|
+
s.add_dependency(%q<erubis>, [">= 0"])
|
99
|
+
s.add_dependency(%q<knjdbrevision>, [">= 0.0.2"])
|
100
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
101
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
102
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
|
103
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
104
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
data/lib/conf/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Here should all config-files be placed.
|
@@ -0,0 +1,109 @@
|
|
1
|
+
rpath = Knj::Php.realpath(File.dirname(__FILE__) + "/../include/class_erbhandler.rb")
|
2
|
+
require rpath
|
3
|
+
erbhandler = Knjappserver::ERBHandler.new
|
4
|
+
|
5
|
+
dbargs = {
|
6
|
+
:type => "mysql",
|
7
|
+
:subtype => "mysql2",
|
8
|
+
:host => "localhost",
|
9
|
+
:user => "username",
|
10
|
+
:pass => "password",
|
11
|
+
:db => "database_name",
|
12
|
+
:return_keys => "symbols",
|
13
|
+
:encoding => "utf8",
|
14
|
+
:threadsafe => true
|
15
|
+
}
|
16
|
+
|
17
|
+
begin
|
18
|
+
options = {
|
19
|
+
:verbose => false,
|
20
|
+
:debug => false,
|
21
|
+
:autorestart => false
|
22
|
+
}
|
23
|
+
OptionParser.new do |opts|
|
24
|
+
opts.banner = "Usage: knjappserver.rb [options]"
|
25
|
+
|
26
|
+
opts.on("-n", "--notice", "Run verbosely.") do |v|
|
27
|
+
print "Running verbosely.\n"
|
28
|
+
options[:verbose] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-r", "--autorestart", "Autorestart the server when a file is changed. This is handy if using the appserver as a development server.") do |autorestart|
|
32
|
+
options[:autorestart] = autorestart
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on("-d", "--debug", "Run in debugging mode.") do |debug|
|
36
|
+
print "Entering debugging mode.\n"
|
37
|
+
options[:debug] = true
|
38
|
+
end
|
39
|
+
end.parse!
|
40
|
+
rescue OptionParser::InvalidOption => e
|
41
|
+
Knj::Php.die(e.message + "\n")
|
42
|
+
end
|
43
|
+
|
44
|
+
$knjappserver[:knjappserver] = Knjappserver.new(
|
45
|
+
:debug => options[:debug],
|
46
|
+
:autorestart => options[:autorestart],
|
47
|
+
:verbose => options[:verbose],
|
48
|
+
:title => "Site name",
|
49
|
+
:port => 13081,
|
50
|
+
:host => "0.0.0.0",
|
51
|
+
:default_page => "index.rhtml",
|
52
|
+
:doc_root => "[path to rhtml files]",
|
53
|
+
:hostname => false,
|
54
|
+
:default_filetype => "text/html",
|
55
|
+
:engine_webrick => true,
|
56
|
+
:error_report_emails => ["admin_email"],
|
57
|
+
:error_report_from => "robot_email",
|
58
|
+
:locales_root => "[path to locale files]",
|
59
|
+
:max_requests_working => 5,
|
60
|
+
:filetypes => {
|
61
|
+
:jpeg => "image/jpeg",
|
62
|
+
:jpg => "image/jpeg",
|
63
|
+
:gif => "image/gif",
|
64
|
+
:png => "image/png",
|
65
|
+
:html => "text/html",
|
66
|
+
:htm => "text/html",
|
67
|
+
:rhtml => "text/html",
|
68
|
+
:css => "text/css",
|
69
|
+
:xml => "text/xml",
|
70
|
+
:js => "text/javascript"
|
71
|
+
},
|
72
|
+
:handlers => [
|
73
|
+
:file_ext => "rhtml",
|
74
|
+
:callback => erbhandler.method(:erb_handler)
|
75
|
+
],
|
76
|
+
:db => Knj::Db.new(
|
77
|
+
:type => "mysql",
|
78
|
+
:subtype => "mysql2",
|
79
|
+
:host => "localhost",
|
80
|
+
:user => "knjappserver",
|
81
|
+
:pass => "password",
|
82
|
+
:db => "knjappserver",
|
83
|
+
:return_keys => "symbols",
|
84
|
+
:encoding => "utf8",
|
85
|
+
:threadsafe => true
|
86
|
+
),
|
87
|
+
:smtp_args => {
|
88
|
+
"smtp_host" => "smtp.server.com",
|
89
|
+
"smtp_port" => 465,
|
90
|
+
"smtp_user" => "robot@server.com",
|
91
|
+
"smtp_passwd" => "password",
|
92
|
+
"ssl" => true
|
93
|
+
},
|
94
|
+
:httpsession_db_args => dbargs
|
95
|
+
)
|
96
|
+
|
97
|
+
if $knjappserver[:knjappserver].config[:autorestart]
|
98
|
+
#Also check config-file for changes.
|
99
|
+
$knjappserver[:knjappserver].mod_event.args[:paths] << rpath
|
100
|
+
end
|
101
|
+
|
102
|
+
if ARGV[0] == "update_db"
|
103
|
+
print "Running DB update script.\n"
|
104
|
+
$knjappserver[:knjappserver].update_db
|
105
|
+
exit
|
106
|
+
end
|
107
|
+
|
108
|
+
Dir.chdir($knjappserver[:knjappserver].config[:doc_root])
|
109
|
+
$knjappserver[:knjappserver].start
|
@@ -0,0 +1,111 @@
|
|
1
|
+
$tables = {
|
2
|
+
"tables" => {
|
3
|
+
"Session" => {
|
4
|
+
"columns" => [
|
5
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
6
|
+
{"name" => "idhash", "type" => "varchar"},
|
7
|
+
{"name" => "sess_data", "type" => "text"},
|
8
|
+
{"name" => "date_added", "type" => "datetime"},
|
9
|
+
{"name" => "ip", "type" => "varchar", "maxlength" => 15}
|
10
|
+
],
|
11
|
+
"indexes" => [
|
12
|
+
{"name" => "date_added", "columns" => ["date_added"]},
|
13
|
+
{"name" => "idhash", "columns" => ["idhash"]}
|
14
|
+
],
|
15
|
+
"renames" => ["sessions"]
|
16
|
+
},
|
17
|
+
"Translation" => {
|
18
|
+
"columns" => [
|
19
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
20
|
+
{"name" => "object_class", "type" => "varchar", "maxlength" => 50},
|
21
|
+
{"name" => "object_id", "type" => "bigint"},
|
22
|
+
{"name" => "key", "type" => "varchar", "maxlength" => 50},
|
23
|
+
{"name" => "locale", "type" => "varchar", "maxlength" => 5},
|
24
|
+
{"name" => "value", "type" => "text"}
|
25
|
+
],
|
26
|
+
"indexes" => [
|
27
|
+
{"name" => "lookup", "columns" => ["object_class", "object_id", "key", "locale"]}
|
28
|
+
],
|
29
|
+
"indexes_remove" => {
|
30
|
+
"object_class" => true
|
31
|
+
},
|
32
|
+
"renames" => ["translations"]
|
33
|
+
},
|
34
|
+
"Log" => {
|
35
|
+
"columns" => [
|
36
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
37
|
+
{"name" => "text_value_id", "type" => "bigint"},
|
38
|
+
{"name" => "date_saved", "type" => "datetime"},
|
39
|
+
{"name" => "get_keys_data_id", "type" => "bigint"},
|
40
|
+
{"name" => "get_values_data_id", "type" => "bigint"},
|
41
|
+
{"name" => "post_keys_data_id", "type" => "bigint"},
|
42
|
+
{"name" => "post_values_data_id", "type" => "bigint"}
|
43
|
+
],
|
44
|
+
"indexes" => [
|
45
|
+
{"name" => "text_value_id", "columns" => ["text_value_id"]}
|
46
|
+
]
|
47
|
+
},
|
48
|
+
"Log_access" => {
|
49
|
+
"columns" => [
|
50
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
51
|
+
{"name" => "session_id", "type" => "bigint"},
|
52
|
+
{"name" => "date_request", "type" => "datetime"},
|
53
|
+
{"name" => "ip_data_id", "type" => "bigint"},
|
54
|
+
{"name" => "get_keys_data_id", "type" => "bigint"},
|
55
|
+
{"name" => "get_values_data_id", "type" => "bigint"},
|
56
|
+
{"name" => "post_keys_data_id", "type" => "bigint"},
|
57
|
+
{"name" => "post_values_data_id", "type" => "bigint"},
|
58
|
+
{"name" => "cookie_keys_data_id", "type" => "bigint"},
|
59
|
+
{"name" => "cookie_values_data_id", "type" => "bigint"},
|
60
|
+
{"name" => "meta_keys_data_id", "type" => "bigint"},
|
61
|
+
{"name" => "meta_values_data_id", "type" => "bigint"}
|
62
|
+
],
|
63
|
+
"indexes" => [
|
64
|
+
{"name" => "session_id", "columns" => ["session_id"]},
|
65
|
+
{"name" => "date_request", "columns" => ["date_request"]}
|
66
|
+
]
|
67
|
+
},
|
68
|
+
"Log_data" => {
|
69
|
+
"columns" => [
|
70
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
71
|
+
{"name" => "id_hash", "type" => "varchar"}
|
72
|
+
],
|
73
|
+
"indexes" => [
|
74
|
+
{"name" => "id_hash", "columns" => ["id_hash"]}
|
75
|
+
]
|
76
|
+
},
|
77
|
+
"Log_data_link" => {
|
78
|
+
"columns" => [
|
79
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
80
|
+
{"name" => "no", "type" => "int"},
|
81
|
+
{"name" => "data_id", "type" => "bigint"},
|
82
|
+
{"name" => "value_id", "type" => "bigint"}
|
83
|
+
],
|
84
|
+
"indexes" => [
|
85
|
+
{"name" => "data_id", "columns" => ["data_id"]},
|
86
|
+
{"name" => "value_id", "columns" => ["value_id"]}
|
87
|
+
]
|
88
|
+
},
|
89
|
+
"Log_data_value" => {
|
90
|
+
"columns" => [
|
91
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
92
|
+
{"name" => "value", "type" => "text"}
|
93
|
+
]
|
94
|
+
},
|
95
|
+
"Log_link" => {
|
96
|
+
"columns" => [
|
97
|
+
{"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true},
|
98
|
+
{"name" => "log_id", "type" => "bigint"},
|
99
|
+
{"name" => "object_class_value_id", "type" => "bigint"},
|
100
|
+
{"name" => "object_id", "type" => "bigint"}
|
101
|
+
],
|
102
|
+
"indexes" => [
|
103
|
+
{"name" => "log_id", "columns" => ["log_id"]},
|
104
|
+
{"name" => "object_id", "columns" => ["object_id"]},
|
105
|
+
{"name" => "object_class_value_id", "columns" => ["object_class_value_id"]},
|
106
|
+
{"name" => "object_lookup", "columns" => ["object_class_value_id", "object_id"]},
|
107
|
+
{"name" => "log_lookup", "columns" => ["object_class_value_id", "object_id", "log_id"]}
|
108
|
+
]
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
A runfile will be placed here named "knjappserver" containing the PID of the process in which it is running.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Knjappserver::CustomIO < StringIO
|
2
|
+
def print(str)
|
3
|
+
thread = Thread.current
|
4
|
+
|
5
|
+
if thread and thread[:knjappserver] and thread[:knjappserver][:stringio] and !thread[:knjappserver][:stringio].closed?
|
6
|
+
return thread[:knjappserver][:stringio].print(str)
|
7
|
+
elsif thread and thread[:knjappserver] and thread[:knjappserver][:httpsession] and thread[:knjappserver][:httpsession].out and !thread[:knjappserver][:httpsession].out.closed?
|
8
|
+
return thread[:knjappserver][:httpsession].out.print(str)
|
9
|
+
else
|
10
|
+
return STDOUT.print(str) if !STDOUT.closed?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def <<(str)
|
15
|
+
self.print(str)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write(str)
|
19
|
+
self.print(str)
|
20
|
+
end
|
21
|
+
end
|