daemon-ogre 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -3
- data/VERSION +1 -1
- data/daemon-ogre.gemspec +2 -1
- data/example/daemonizable.rb +6 -4
- data/lib/daemon-ogre.rb +5 -6
- data/lib/daemon-ogre/daemon.rb +0 -3
- data/lib/daemon-ogre/opts.rb +39 -21
- metadata +20 -8
- data/test/example.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ac6b5568ddd979373abac556fb64eb9d0249870
|
4
|
+
data.tar.gz: 62a1d719cc292857bf29445d55ebd1beaa2c2ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79113227fd66e6133a81baf23a93cc82a78b36eb0f4d77b8e1840356491247ac828e65de0c4441a4c357e874ecafe3f824d31d6412fcde710a4a9f7e52424e90
|
7
|
+
data.tar.gz: bda1cdf3945e0617029e7235cff99d629d714e3c1d7bf6ece52e9142aae20dc146c13ffaeca750eafbd9104096c9ab6ee776fa90b591f2cf4d19845d5d62dbda
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
daemon-ogre (2.
|
5
|
-
|
4
|
+
daemon-ogre (2.2.0)
|
5
|
+
configer
|
6
|
+
tmp (>= 4.1.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: http://rubygems.org/
|
9
10
|
specs:
|
11
|
+
configer (2.1.0)
|
10
12
|
rake (10.0.4)
|
11
|
-
tmp (
|
13
|
+
tmp (4.1.0)
|
12
14
|
|
13
15
|
PLATFORMS
|
14
16
|
ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/daemon-ogre.gemspec
CHANGED
@@ -16,7 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency 'tmp', '>=
|
19
|
+
spec.add_dependency 'tmp', '>= 4.1.0'
|
20
|
+
spec.add_dependency 'configer'
|
20
21
|
|
21
22
|
spec.add_development_dependency 'bundler'
|
22
23
|
spec.add_development_dependency 'rake'
|
data/example/daemonizable.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'..','lib'))
|
1
2
|
require 'daemon-ogre'
|
2
3
|
|
3
4
|
# start as
|
4
5
|
# ruby sample_daemon_app.rb --daemon
|
5
6
|
# puts "app name: #{$0}"
|
7
|
+
ARGV.unshift '--daemon'
|
8
|
+
puts "ps aux | grep #{$0}"
|
9
|
+
puts "tail -f #{DaemonOgre::OPTS.tmp_folder_path}/*"
|
6
10
|
|
7
11
|
DaemonOgre.init
|
8
12
|
|
9
|
-
|
13
|
+
10.times do
|
10
14
|
|
11
15
|
puts Time.now
|
12
16
|
sleep 1
|
13
17
|
|
14
18
|
end
|
15
19
|
|
16
|
-
|
17
|
-
# to check it's running
|
18
|
-
`ps aux | grep $0`
|
20
|
+
raise('some err')
|
data/lib/daemon-ogre.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
require 'daemon-ogre/
|
5
|
-
|
6
|
-
require 'daemon-ogre/daemon'
|
1
|
+
module DaemonOgre
|
2
|
+
require 'daemon-ogre/opts'
|
3
|
+
require 'daemon-ogre/argv'
|
4
|
+
require 'daemon-ogre/daemon'
|
5
|
+
end
|
data/lib/daemon-ogre/daemon.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# use Daemon.daemonize or Process.daemonize
|
2
2
|
module DaemonOgre
|
3
|
-
|
4
3
|
module Daemon
|
5
4
|
|
6
5
|
class << self
|
7
6
|
|
8
|
-
|
9
7
|
# Checks to see if the current process is the child process and if not
|
10
8
|
# will update the pid file with the child pid.
|
11
9
|
def start pid
|
@@ -174,7 +172,6 @@ module DaemonOgre
|
|
174
172
|
def init
|
175
173
|
Daemon.init
|
176
174
|
end
|
177
|
-
# alias :new :init
|
178
175
|
end
|
179
176
|
|
180
177
|
end
|
data/lib/daemon-ogre/opts.rb
CHANGED
@@ -1,35 +1,53 @@
|
|
1
|
+
require 'tmp'
|
2
|
+
require 'configer'
|
1
3
|
module DaemonOgre
|
2
4
|
|
3
5
|
module OPTS
|
4
|
-
class << self
|
5
6
|
|
6
|
-
|
7
|
-
@@path ||= nil
|
8
|
-
@@path = obj unless obj.nil?
|
9
|
-
@@path || "#{::TMP.folder_path.to_s}_daemon"
|
10
|
-
end
|
7
|
+
extend self
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
def tmp_folder_path(obj= nil)
|
10
|
+
@path ||= nil
|
11
|
+
@path = obj unless obj.nil?
|
12
|
+
@path || __temp__.tmpdir
|
13
|
+
end
|
15
14
|
|
16
|
-
def pid= *args
|
17
|
-
self.pidfile= *args
|
18
|
-
end
|
19
15
|
|
20
|
-
|
16
|
+
def pid
|
17
|
+
pid_number = nil
|
18
|
+
__temp__.open('pid','r+'){|f| pid_number = f.read.chomp }
|
19
|
+
return pid_number
|
20
|
+
end
|
21
21
|
|
22
|
-
|
22
|
+
def pidfile=(pid_number)
|
23
|
+
__temp__.open('pid','w'){|f| f.write(pid_number.to_s) }
|
24
|
+
end
|
23
25
|
|
24
|
-
if method_name.to_s.reverse[0] == "="
|
25
|
-
@@tmp_dsl.__send__ method_name,args[0]
|
26
|
-
else
|
27
|
-
@@tmp_dsl.__send__ method_name
|
28
|
-
end
|
29
26
|
|
30
|
-
|
27
|
+
def out__path__
|
28
|
+
__temp__.path_for('out')
|
29
|
+
end
|
31
30
|
|
31
|
+
def err__path__
|
32
|
+
__temp__.path_for('err')
|
32
33
|
end
|
33
|
-
end
|
34
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
def __temp__
|
38
|
+
@__temp__ ||= __get_temp_dir
|
39
|
+
end
|
40
|
+
|
41
|
+
def __get_temp_dir
|
42
|
+
require 'tmpdir'
|
43
|
+
temp_folder = File.join(::Dir.tmpdir.to_s, "#{__project_name__}_daemon")
|
44
|
+
Dir.mkdir(temp_folder) unless File.exist?(temp_folder)
|
45
|
+
TMP.new(temp_folder)
|
46
|
+
end
|
47
|
+
|
48
|
+
def __project_name__
|
49
|
+
::Configer.pwd.split(File::Separator)[-1]
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
35
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemon-ogre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tmp
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: configer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +86,6 @@ files:
|
|
72
86
|
- lib/daemon-ogre/argv.rb
|
73
87
|
- lib/daemon-ogre/daemon.rb
|
74
88
|
- lib/daemon-ogre/opts.rb
|
75
|
-
- test/example.rb
|
76
89
|
homepage: http://github.com/adamluzsi/daemon-ogre
|
77
90
|
licenses: []
|
78
91
|
metadata: {}
|
@@ -92,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
105
|
version: '0'
|
93
106
|
requirements: []
|
94
107
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.2.2
|
96
109
|
signing_key:
|
97
110
|
specification_version: 4
|
98
111
|
summary: Simple to use app ARGV based daemonizer
|
99
|
-
test_files:
|
100
|
-
- test/example.rb
|
112
|
+
test_files: []
|
data/test/example.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative "daemon-ogre"
|
2
|
-
|
3
|
-
DaemonOgre.start :name => "api_one", #this will be the name of the application
|
4
|
-
:log_path => "./var/log/log_file_name", #this will be the logfile place and name
|
5
|
-
:pid_path => "./var/pid/pid_file_name", #this will be the pidfile place and name
|
6
|
-
:terminate => true, #this command not let start your code if it's not started
|
7
|
-
:clear => true # with "start" arguments like :
|
8
|
-
# ruby my_awsome_app.rb start
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
#my awesome Hello App
|
13
|
-
puts "hello App!"
|
14
|
-
|
15
|
-
i=0
|
16
|
-
until i > 1200
|
17
|
-
sleep 1
|
18
|
-
i+=1
|
19
|
-
end
|