workety 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +5 -0
- data/ISSUE_TEMPLATE.md +5 -0
- data/LICENSE +202 -0
- data/PULL_REQUEST_TEMPLATE.md +5 -0
- data/README.md +120 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/bin/workety +359 -0
- data/lib/workety.rb +53 -0
- data/lib/workety/extensions/exception.rb +140 -0
- data/lib/workety/extensions/exceptional.rb +52 -0
- data/lib/workety/extensions/kernel.rb +28 -0
- data/lib/workety/extensions/process.rb +38 -0
- data/lib/workety/extensions/signal.rb +31 -0
- data/lib/workety/extensions/socket.rb +51 -0
- data/lib/workety/extensions/thread.rb +109 -0
- data/lib/workety/test/graceful_stop_thread.rb +46 -0
- data/lib/workety/test/simple_thread.rb +42 -0
- data/lib/workety/test/test_thread.rb +89 -0
- data/lib/workety/timed_exit.rb +56 -0
- data/lib/workety/workety.rb +135 -0
- data/test/exception_tracker.rb +7 -0
- data/test/logger_init.rb +26 -0
- data/test/mem_and_load_path.rb +8 -0
- data/test/new_thread_on_signal.rb +39 -0
- data/test/server_socket_close.rb +46 -0
- data/test/server_socket_shutdown.rb +47 -0
- data/test/signal_handler_exception.rb +32 -0
- data/test/stdin_eof.rb +26 -0
- data/workety.gemspec +70 -0
- metadata +90 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
# Copyright 2006-2011 Stanislav Senotrusov <stan@senotrusov.com>
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'thread'
|
17
|
+
require 'socket'
|
18
|
+
|
19
|
+
s=TCPServer.new("127.0.0.1", 9999)
|
20
|
+
|
21
|
+
t = Thread.new do
|
22
|
+
begin
|
23
|
+
loop do
|
24
|
+
puts "ACCEPTING"
|
25
|
+
puts s.accept.inspect
|
26
|
+
puts "ACCEPTED"
|
27
|
+
end
|
28
|
+
puts "DONE"
|
29
|
+
rescue Exception => ex
|
30
|
+
puts "EX"
|
31
|
+
puts ex.inspect #<Errno::EBADF: Bad file descriptor>
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
c = Thread.new do
|
36
|
+
s.close
|
37
|
+
puts "Closed"
|
38
|
+
t.run # Without that there are no error raised from accept()
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
t.join
|
43
|
+
c.join
|
44
|
+
|
45
|
+
|
46
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
# Copyright 2006-2011 Stanislav Senotrusov <stan@senotrusov.com>
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'thread'
|
17
|
+
require 'socket'
|
18
|
+
|
19
|
+
s=TCPServer.new("127.0.0.1", 9999)
|
20
|
+
|
21
|
+
t = Thread.new do
|
22
|
+
begin
|
23
|
+
loop do
|
24
|
+
puts "ACCEPTING"
|
25
|
+
puts s.accept.inspect
|
26
|
+
puts "ACCEPTED"
|
27
|
+
end
|
28
|
+
puts "DONE"
|
29
|
+
rescue Exception => ex
|
30
|
+
puts "EX"
|
31
|
+
puts ex.inspect #<Errno::EINVAL: Invalid argument>
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
c = Thread.new do
|
36
|
+
s.shutdown
|
37
|
+
# t.run # here leads to #<Errno::EBADF: Bad file descriptor> insted of Errno::EINVAL
|
38
|
+
sleep 1 # Without that sleep exception will not raised in t
|
39
|
+
s.close
|
40
|
+
puts "Closed"
|
41
|
+
end
|
42
|
+
|
43
|
+
t.join
|
44
|
+
c.join
|
45
|
+
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
# Copyright 2006-2011 Stanislav Senotrusov <stan@senotrusov.com>
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
begin
|
17
|
+
h = Proc.new do
|
18
|
+
error
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
Signal.trap('TERM', & h)
|
24
|
+
|
25
|
+
Process.kill("TERM", Process.pid)
|
26
|
+
|
27
|
+
sleep 10
|
28
|
+
rescue Exception => ex
|
29
|
+
puts "foo"
|
30
|
+
puts ex.inspect
|
31
|
+
puts ex.backtrace.join("\n")
|
32
|
+
end
|
data/test/stdin_eof.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
# Copyright 2006-2011 Stanislav Senotrusov <stan@senotrusov.com>
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
loop do
|
17
|
+
puts 'loop'
|
18
|
+
begin
|
19
|
+
puts ">>>>> " + STDIN.read_nonblock(10)
|
20
|
+
rescue Errno::EAGAIN
|
21
|
+
rescue EOFError
|
22
|
+
puts "EOF"
|
23
|
+
Process.exit
|
24
|
+
end
|
25
|
+
sleep 0.5
|
26
|
+
end
|
data/workety.gemspec
ADDED
@@ -0,0 +1,70 @@
|
|
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
|
+
# stub: workety 2.0.3 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "workety"
|
9
|
+
s.version = "2.0.3"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Stanislav Senotrusov"]
|
14
|
+
s.date = "2017-04-23"
|
15
|
+
s.email = "stan@senotrusov.com"
|
16
|
+
s.executables = ["workety"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"CONTRIBUTING.md",
|
23
|
+
"ISSUE_TEMPLATE.md",
|
24
|
+
"LICENSE",
|
25
|
+
"PULL_REQUEST_TEMPLATE.md",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/workety",
|
30
|
+
"lib/workety.rb",
|
31
|
+
"lib/workety/extensions/exception.rb",
|
32
|
+
"lib/workety/extensions/exceptional.rb",
|
33
|
+
"lib/workety/extensions/kernel.rb",
|
34
|
+
"lib/workety/extensions/process.rb",
|
35
|
+
"lib/workety/extensions/signal.rb",
|
36
|
+
"lib/workety/extensions/socket.rb",
|
37
|
+
"lib/workety/extensions/thread.rb",
|
38
|
+
"lib/workety/test/graceful_stop_thread.rb",
|
39
|
+
"lib/workety/test/simple_thread.rb",
|
40
|
+
"lib/workety/test/test_thread.rb",
|
41
|
+
"lib/workety/timed_exit.rb",
|
42
|
+
"lib/workety/workety.rb",
|
43
|
+
"test/exception_tracker.rb",
|
44
|
+
"test/logger_init.rb",
|
45
|
+
"test/mem_and_load_path.rb",
|
46
|
+
"test/new_thread_on_signal.rb",
|
47
|
+
"test/server_socket_close.rb",
|
48
|
+
"test/server_socket_shutdown.rb",
|
49
|
+
"test/signal_handler_exception.rb",
|
50
|
+
"test/stdin_eof.rb",
|
51
|
+
"workety.gemspec"
|
52
|
+
]
|
53
|
+
s.homepage = "https://github.com/senotrusov/workety"
|
54
|
+
s.licenses = ["Apache-2.0"]
|
55
|
+
s.rubygems_version = "2.5.1"
|
56
|
+
s.summary = "Run Ruby/Rails code as a worker: detach, signals, watchdog, threads, reporting"
|
57
|
+
|
58
|
+
if s.respond_to? :specification_version then
|
59
|
+
s.specification_version = 4
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
|
+
s.add_runtime_dependency(%q<trollop>, [">= 0"])
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<trollop>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<trollop>, [">= 0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: workety
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stanislav Senotrusov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: trollop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email: stan@senotrusov.com
|
29
|
+
executables:
|
30
|
+
- workety
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
files:
|
36
|
+
- CONTRIBUTING.md
|
37
|
+
- ISSUE_TEMPLATE.md
|
38
|
+
- LICENSE
|
39
|
+
- PULL_REQUEST_TEMPLATE.md
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- VERSION
|
43
|
+
- bin/workety
|
44
|
+
- lib/workety.rb
|
45
|
+
- lib/workety/extensions/exception.rb
|
46
|
+
- lib/workety/extensions/exceptional.rb
|
47
|
+
- lib/workety/extensions/kernel.rb
|
48
|
+
- lib/workety/extensions/process.rb
|
49
|
+
- lib/workety/extensions/signal.rb
|
50
|
+
- lib/workety/extensions/socket.rb
|
51
|
+
- lib/workety/extensions/thread.rb
|
52
|
+
- lib/workety/test/graceful_stop_thread.rb
|
53
|
+
- lib/workety/test/simple_thread.rb
|
54
|
+
- lib/workety/test/test_thread.rb
|
55
|
+
- lib/workety/timed_exit.rb
|
56
|
+
- lib/workety/workety.rb
|
57
|
+
- test/exception_tracker.rb
|
58
|
+
- test/logger_init.rb
|
59
|
+
- test/mem_and_load_path.rb
|
60
|
+
- test/new_thread_on_signal.rb
|
61
|
+
- test/server_socket_close.rb
|
62
|
+
- test/server_socket_shutdown.rb
|
63
|
+
- test/signal_handler_exception.rb
|
64
|
+
- test/stdin_eof.rb
|
65
|
+
- workety.gemspec
|
66
|
+
homepage: https://github.com/senotrusov/workety
|
67
|
+
licenses:
|
68
|
+
- Apache-2.0
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: 'Run Ruby/Rails code as a worker: detach, signals, watchdog, threads, reporting'
|
90
|
+
test_files: []
|