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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e2e72f8f2cec1041946fbc40dc1fd0800440bfd
4
- data.tar.gz: defa4621c6d460432298430ebebdf7b1bac598e0
3
+ metadata.gz: 6ac6b5568ddd979373abac556fb64eb9d0249870
4
+ data.tar.gz: 62a1d719cc292857bf29445d55ebd1beaa2c2ed2
5
5
  SHA512:
6
- metadata.gz: 7c760ff529c3bffa637421be4ea440ea4fd66abf821c8d6fa0fcd548f07b0a173b456bb722cdedde245fa74034032008436e56e36ab20558b72885849ffdc2cf
7
- data.tar.gz: a1991e7b9a9956737bd239a68587a334004fb234c492ecd5d5057b61cd7e8581a4547efbca8cb562bed24b6cfe3be25b078ae21c1fbc1756aee15cc00ec94d61
6
+ metadata.gz: 79113227fd66e6133a81baf23a93cc82a78b36eb0f4d77b8e1840356491247ac828e65de0c4441a4c357e874ecafe3f824d31d6412fcde710a4a9f7e52424e90
7
+ data.tar.gz: bda1cdf3945e0617029e7235cff99d629d714e3c1d7bf6ece52e9142aae20dc146c13ffaeca750eafbd9104096c9ab6ee776fa90b591f2cf4d19845d5d62dbda
@@ -1,14 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- daemon-ogre (2.1.3)
5
- tmp (>= 2.2.2)
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 (3.1.0)
13
+ tmp (4.1.0)
12
14
 
13
15
  PLATFORMS
14
16
  ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.2.0
@@ -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', '>= 2.2.2'
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'
@@ -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
- 60.times do
13
+ 10.times do
10
14
 
11
15
  puts Time.now
12
16
  sleep 1
13
17
 
14
18
  end
15
19
 
16
- sleep 1
17
- # to check it's running
18
- `ps aux | grep $0`
20
+ raise('some err')
@@ -1,6 +1,5 @@
1
-
2
- require 'tmp'
3
-
4
- require 'daemon-ogre/opts'
5
- require 'daemon-ogre/argv'
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
@@ -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
@@ -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
- def tmp_folder_path obj= nil
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
- def pid *args
13
- self.pidfile
14
- end
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
- def method_missing method_name, *args
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
- @@tmp_dsl ||= ::TMP.new( self.tmp_folder_path )
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
- end
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.1.3
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: 2014-12-11 00:00:00.000000000 Z
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: 2.2.2
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: 2.2.2
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.4.3
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: []
@@ -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