knjappserver 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,14 +6,14 @@ source "http://rubygems.org"
6
6
  gem "knjrbfw"
7
7
  gem "erubis"
8
8
  gem "mail"
9
+ gem "tsafe"
9
10
 
10
11
  # Add dependencies to develop your gem here.
11
12
  # Include everything needed to run rake, tests, features, etc.
12
13
  group :development do
13
14
  gem "rspec", "~> 2.3.0"
14
- gem "bundler", "~> 1.0.0"
15
+ gem "bundler", ">= 1.0.0"
15
16
  gem "jeweler", "~> 1.6.3"
16
17
  gem "rcov", ">= 0"
17
18
  gem "sqlite3" if RUBY_ENGINE != "jruby"
18
- gem "json"
19
19
  end
data/Gemfile.lock CHANGED
@@ -9,8 +9,6 @@ GEM
9
9
  bundler (~> 1.0)
10
10
  git (>= 1.2.5)
11
11
  rake
12
- json (1.6.1)
13
- json (1.6.1-java)
14
12
  knjrbfw (0.0.8)
15
13
  mail (2.3.0)
16
14
  i18n (>= 0.4.0)
@@ -33,18 +31,19 @@ GEM
33
31
  treetop (1.4.10)
34
32
  polyglot
35
33
  polyglot (>= 0.3.1)
34
+ tsafe (0.0.1)
36
35
 
37
36
  PLATFORMS
38
37
  java
39
38
  ruby
40
39
 
41
40
  DEPENDENCIES
42
- bundler (~> 1.0.0)
41
+ bundler (>= 1.0.0)
43
42
  erubis
44
43
  jeweler (~> 1.6.3)
45
- json
46
44
  knjrbfw
47
45
  mail
48
46
  rcov
49
47
  rspec (~> 2.3.0)
50
48
  sqlite3
49
+ tsafe
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.22
1
+ 0.0.23
data/knjappserver.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knjappserver}
8
- s.version = "0.0.22"
8
+ s.version = "0.0.23"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = %q{2012-05-03}
12
+ s.date = %q{2012-05-22}
13
13
  s.description = %q{Which supports a lot of undocumented stuff.}
14
14
  s.email = %q{k@spernj.org}
15
15
  s.executables = ["check_running.rb", "knjappserver_start.rb"]
@@ -103,33 +103,33 @@ Gem::Specification.new do |s|
103
103
  s.add_runtime_dependency(%q<knjrbfw>, [">= 0"])
104
104
  s.add_runtime_dependency(%q<erubis>, [">= 0"])
105
105
  s.add_runtime_dependency(%q<mail>, [">= 0"])
106
+ s.add_runtime_dependency(%q<tsafe>, [">= 0"])
106
107
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
107
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
108
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
108
109
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
109
110
  s.add_development_dependency(%q<rcov>, [">= 0"])
110
111
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
111
- s.add_development_dependency(%q<json>, [">= 0"])
112
112
  else
113
113
  s.add_dependency(%q<knjrbfw>, [">= 0"])
114
114
  s.add_dependency(%q<erubis>, [">= 0"])
115
115
  s.add_dependency(%q<mail>, [">= 0"])
116
+ s.add_dependency(%q<tsafe>, [">= 0"])
116
117
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
117
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
118
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
118
119
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
119
120
  s.add_dependency(%q<rcov>, [">= 0"])
120
121
  s.add_dependency(%q<sqlite3>, [">= 0"])
121
- s.add_dependency(%q<json>, [">= 0"])
122
122
  end
123
123
  else
124
124
  s.add_dependency(%q<knjrbfw>, [">= 0"])
125
125
  s.add_dependency(%q<erubis>, [">= 0"])
126
126
  s.add_dependency(%q<mail>, [">= 0"])
127
+ s.add_dependency(%q<tsafe>, [">= 0"])
127
128
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
128
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
129
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
129
130
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
130
131
  s.add_dependency(%q<rcov>, [">= 0"])
131
132
  s.add_dependency(%q<sqlite3>, [">= 0"])
132
- s.add_dependency(%q<json>, [">= 0"])
133
133
  end
134
134
  end
135
135
 
@@ -128,6 +128,7 @@ class Knjappserver
128
128
  require "base64"
129
129
  require "stringio"
130
130
  require "socket"
131
+ require "tsafe"
131
132
 
132
133
  files += [
133
134
  "#{@path_knjrbfw}knj/event_handler.rb",
@@ -3,10 +3,11 @@ class Knjappserver
3
3
 
4
4
  def initialize_mailing
5
5
  require "knj/autoload/ping"
6
+ require "monitor"
6
7
 
7
8
  @mails_waiting = []
8
- @mails_mutex = Mutex.new
9
- @mails_queue_mutex = Mutex.new
9
+ @mails_mutex = Monitor.new
10
+ @mails_queue_mutex = Monitor.new
10
11
  @mails_timeout = self.timeout(:time => 10) do
11
12
  self.mail_flush
12
13
  end
@@ -29,7 +30,8 @@ class Knjappserver
29
30
 
30
31
  mailobj = Knjappserver::Mail.new({:kas => self, :errors => {}, :status => :waiting}.merge(mail_args))
31
32
  STDOUT.print "Added mail '#{mailobj.__id__}' to the mail-send-queue.\n" if debug
32
- @mails_waiting << mailobj
33
+ @mails_waiting << mailobj if mail_args[:now]
34
+ self.mail_flush
33
35
  return mailobj
34
36
  end
35
37
  end
@@ -1,6 +1,7 @@
1
1
  class Knjappserver
2
2
  def initialize_sessions
3
- @sessions = {}
3
+ require "tsafe"
4
+ @sessions = Tsafe::MonHash.new
4
5
  end
5
6
 
6
7
  #Returns or adds session based on idhash and meta-data.
@@ -2,9 +2,9 @@ class Knjappserver::Session < Knj::Datarow
2
2
  attr_reader :edata
3
3
  attr_accessor :sess_data
4
4
 
5
- def initialize(d)
5
+ def initialize(*args, &block)
6
6
  @edata = {}
7
- super(d)
7
+ super(*args, &block)
8
8
 
9
9
  if self[:sess_data].to_s.length > 0
10
10
  begin
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby1.9.1
2
2
 
3
- time_begin = Time.now
4
-
5
3
  #This scripts start an appserver, executes a HTTP-request and terminates.
6
4
  #Good for programming appserver-supported projects without running an appserver all the time,
7
5
  #but really slow because of startup for every request.
@@ -65,21 +63,19 @@ begin
65
63
  :cleaner => false,
66
64
  :dbrev => false,
67
65
  :mail_require => false,
66
+ :debug => false,
68
67
  :port => 0 #Ruby picks random port and we get the actual port after starting the appserver.
69
68
  }.merge(Knjappserver::CGI_CONF["knjappserver"])
70
69
  knjappserver = Knjappserver.new(knjappserver_conf)
71
70
  knjappserver.start
72
71
  port = knjappserver.port
73
72
 
74
-
75
73
  #Make request.
76
74
  http = Knj::Http2.new(:host => "localhost", :port => port)
77
75
 
78
-
79
76
  #Spawn CGI-variable to emulate FCGI part.
80
77
  cgi = Cgi_is_retarded.new
81
78
 
82
-
83
79
  #The rest is copied from the FCGI-part.
84
80
  headers = {}
85
81
  cgi.env_table.each do |key, val|
@@ -136,9 +132,13 @@ begin
136
132
  })
137
133
  end
138
134
  rescue Exception => e
139
- knjappserver.stop
140
-
141
135
  print "Content-Type: text/html\r\n"
142
136
  print "\n\n"
143
137
  print Knj::Errors.error_str(e, {:html => true})
138
+
139
+ begin
140
+ knjappserver.stop if knjappserver
141
+ rescue => e
142
+ print "<br />\n<br />\n" + Knj::Errors.error_str(e, {:html => true})
143
+ end
144
144
  end
metadata CHANGED
@@ -1,126 +1,128 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: knjappserver
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.22
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.0.23
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Kasper Johansen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-03 00:00:00.000000000 +02:00
12
+
13
+ date: 2012-05-22 00:00:00 +02:00
13
14
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
16
17
  name: knjrbfw
17
- requirement: &16549300 !ruby/object:Gem::Requirement
18
+ requirement: &id001 !ruby/object:Gem::Requirement
18
19
  none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
23
24
  type: :runtime
24
25
  prerelease: false
25
- version_requirements: *16549300
26
- - !ruby/object:Gem::Dependency
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
27
28
  name: erubis
28
- requirement: &16547440 !ruby/object:Gem::Requirement
29
+ requirement: &id002 !ruby/object:Gem::Requirement
29
30
  none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
34
35
  type: :runtime
35
36
  prerelease: false
36
- version_requirements: *16547440
37
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
38
39
  name: mail
39
- requirement: &16546360 !ruby/object:Gem::Requirement
40
+ requirement: &id003 !ruby/object:Gem::Requirement
40
41
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
45
46
  type: :runtime
46
47
  prerelease: false
47
- version_requirements: *16546360
48
- - !ruby/object:Gem::Dependency
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: tsafe
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
49
61
  name: rspec
50
- requirement: &16542740 !ruby/object:Gem::Requirement
62
+ requirement: &id005 !ruby/object:Gem::Requirement
51
63
  none: false
52
- requirements:
64
+ requirements:
53
65
  - - ~>
54
- - !ruby/object:Gem::Version
66
+ - !ruby/object:Gem::Version
55
67
  version: 2.3.0
56
68
  type: :development
57
69
  prerelease: false
58
- version_requirements: *16542740
59
- - !ruby/object:Gem::Dependency
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
60
72
  name: bundler
61
- requirement: &16525460 !ruby/object:Gem::Requirement
73
+ requirement: &id006 !ruby/object:Gem::Requirement
62
74
  none: false
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
66
78
  version: 1.0.0
67
79
  type: :development
68
80
  prerelease: false
69
- version_requirements: *16525460
70
- - !ruby/object:Gem::Dependency
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
71
83
  name: jeweler
72
- requirement: &16523980 !ruby/object:Gem::Requirement
84
+ requirement: &id007 !ruby/object:Gem::Requirement
73
85
  none: false
74
- requirements:
86
+ requirements:
75
87
  - - ~>
76
- - !ruby/object:Gem::Version
88
+ - !ruby/object:Gem::Version
77
89
  version: 1.6.3
78
90
  type: :development
79
91
  prerelease: false
80
- version_requirements: *16523980
81
- - !ruby/object:Gem::Dependency
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
82
94
  name: rcov
83
- requirement: &16522600 !ruby/object:Gem::Requirement
95
+ requirement: &id008 !ruby/object:Gem::Requirement
84
96
  none: false
85
- requirements:
86
- - - ! '>='
87
- - !ruby/object:Gem::Version
88
- version: '0'
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
89
101
  type: :development
90
102
  prerelease: false
91
- version_requirements: *16522600
92
- - !ruby/object:Gem::Dependency
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
93
105
  name: sqlite3
94
- requirement: &16521620 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- type: :development
101
- prerelease: false
102
- version_requirements: *16521620
103
- - !ruby/object:Gem::Dependency
104
- name: json
105
- requirement: &16520740 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
106
107
  none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
111
112
  type: :development
112
113
  prerelease: false
113
- version_requirements: *16520740
114
+ version_requirements: *id009
114
115
  description: Which supports a lot of undocumented stuff.
115
116
  email: k@spernj.org
116
- executables:
117
+ executables:
117
118
  - check_running.rb
118
119
  - knjappserver_start.rb
119
120
  extensions: []
120
- extra_rdoc_files:
121
+
122
+ extra_rdoc_files:
121
123
  - LICENSE.txt
122
124
  - README.rdoc
123
- files:
125
+ files:
124
126
  - .document
125
127
  - .rspec
126
128
  - Gemfile
@@ -194,31 +196,34 @@ files:
194
196
  - spec/spec_helper.rb
195
197
  has_rdoc: true
196
198
  homepage: http://github.com/kaspernj/knjappserver
197
- licenses:
199
+ licenses:
198
200
  - MIT
199
201
  post_install_message:
200
202
  rdoc_options: []
201
- require_paths:
203
+
204
+ require_paths:
202
205
  - lib
203
- required_ruby_version: !ruby/object:Gem::Requirement
206
+ required_ruby_version: !ruby/object:Gem::Requirement
204
207
  none: false
205
- requirements:
206
- - - ! '>='
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- segments:
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ hash: -4394912517920739657
212
+ segments:
210
213
  - 0
211
- hash: 2394284405486771539
212
- required_rubygems_version: !ruby/object:Gem::Requirement
214
+ version: "0"
215
+ required_rubygems_version: !ruby/object:Gem::Requirement
213
216
  none: false
214
- requirements:
215
- - - ! '>='
216
- - !ruby/object:Gem::Version
217
- version: '0'
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: "0"
218
221
  requirements: []
222
+
219
223
  rubyforge_project:
220
224
  rubygems_version: 1.6.2
221
225
  signing_key:
222
226
  specification_version: 3
223
227
  summary: A multi-threadded app-web-server.
224
228
  test_files: []
229
+