daemon-ogre 1.5.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ module DaemonOgre
2
+
3
+ module OPTS
4
+ class << self
5
+
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
11
+
12
+ def pid
13
+ self.pidfile
14
+ end
15
+
16
+ def pid= *args
17
+ self.pidfile= *args
18
+ end
19
+
20
+ def method_missing method_name, *args
21
+ @@tmp_dsl ||= ::TMP.new( self.tmp_folder_path )
22
+
23
+ if method_name.to_s.reverse[0] == "="
24
+ @@tmp_dsl.__send__ method_name,args[0]
25
+ else
26
+ @@tmp_dsl.__send__ method_name
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ end
data/lib/daemon-ogre.rb CHANGED
@@ -1,6 +1,7 @@
1
- require File.join File.dirname(__FILE__) , 'daemon-ogre', 'support'
2
- require File.join File.dirname(__FILE__) , 'daemon-ogre', 'app'
3
- require File.join File.dirname(__FILE__) , 'daemon-ogre', 'daemon'
4
- require File.join File.dirname(__FILE__) , 'daemon-ogre', 'server'
5
- require File.join File.dirname(__FILE__) , 'daemon-ogre', 'mpatch'
6
- require File.join File.dirname(__FILE__) , 'daemon-ogre', 'startup'
1
+
2
+ require 'tmp'
3
+ require 'argv'
4
+
5
+ require 'daemon-ogre/opts'
6
+ require 'daemon-ogre/argv'
7
+ require 'daemon-ogre/daemon'
@@ -1,4 +1,4 @@
1
- require_relative "../lib/daemon-ogre.rb"
1
+ require_relative "daemon-ogre"
2
2
 
3
3
  DaemonOgre.start :name => "api_one", #this will be the name of the application
4
4
  :log_path => "./var/log/log_file_name", #this will be the logfile place and name
data/test/test.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ keys= [:d,:daemon,:daemonize]
3
+ puts ( keys && [:d] ).inspect# == keys
metadata CHANGED
@@ -1,46 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemon-ogre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Adam.Luzsi
7
+ - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-02 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: argv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: tmp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
13
69
  description: Simple to use app ARGV based daemonizer
14
- email: adamluzsi@gmail.com
70
+ email:
71
+ - adamluzsi@gmail.com
15
72
  executables: []
16
73
  extensions: []
17
- extra_rdoc_files:
18
- - LICENSE.txt
19
- - README.md
20
- - README.rdoc
74
+ extra_rdoc_files: []
21
75
  files:
76
+ - ".gitignore"
22
77
  - Gemfile
23
78
  - Gemfile.lock
24
79
  - LICENSE.txt
25
80
  - README.md
26
- - README.rdoc
27
81
  - Rakefile
28
82
  - VERSION
29
83
  - daemon-ogre.gemspec
30
- - example/sample_daemon_app.rb
31
- - files.rb
84
+ - example/daemonizable.rb
32
85
  - lib/daemon-ogre.rb
33
- - lib/daemon-ogre/app.rb
86
+ - lib/daemon-ogre/argv.rb
34
87
  - lib/daemon-ogre/daemon.rb
35
- - lib/daemon-ogre/mpatch.rb
36
- - lib/daemon-ogre/server.rb
37
- - lib/daemon-ogre/startup.rb
38
- - lib/daemon-ogre/support.rb
39
- - test/helper.rb
40
- - test/test_daemon-ogre.rb
88
+ - lib/daemon-ogre/opts.rb
89
+ - test/example.rb
90
+ - test/test.rb
41
91
  homepage: http://github.com/adamluzsi/daemon-ogre
42
- licenses:
43
- - MIT
92
+ licenses: []
44
93
  metadata: {}
45
94
  post_install_message:
46
95
  rdoc_options: []
@@ -48,21 +97,20 @@ require_paths:
48
97
  - lib
49
98
  required_ruby_version: !ruby/object:Gem::Requirement
50
99
  requirements:
51
- - - ! '>='
100
+ - - ">="
52
101
  - !ruby/object:Gem::Version
53
102
  version: '0'
54
103
  required_rubygems_version: !ruby/object:Gem::Requirement
55
104
  requirements:
56
- - - ! '>='
105
+ - - ">="
57
106
  - !ruby/object:Gem::Version
58
107
  version: '0'
59
108
  requirements: []
60
109
  rubyforge_project:
61
- rubygems_version: 2.2.1
110
+ rubygems_version: 2.2.2
62
111
  signing_key:
63
112
  specification_version: 4
64
- summary: DSL for helping make file loads and configuration objects
113
+ summary: Simple to use app ARGV based daemonizer
65
114
  test_files:
66
- - test/helper.rb
67
- - test/test_daemon-ogre.rb
68
- has_rdoc:
115
+ - test/example.rb
116
+ - test/test.rb
data/README.rdoc DELETED
@@ -1,247 +0,0 @@
1
- daemon-ogre
2
- ===========
3
-
4
- Description
5
- -----------
6
-
7
- This gem is made for one purpose.
8
-
9
- Ruby meant to be for easy use, not hardcore coding!
10
- And in terms for this, ogre will aid you in the brute way, so you can relax...
11
-
12
- Are you need load a whole bunch of folders to your rack application ?
13
- Do it! You want one nice hash for config constant
14
- from ymls all over your dirs? sure you can! you want have
15
- start/stop/status/restart/daemon/etc argument commands from
16
- terminal to control your application without any fuss?
17
- There you go! Are you need an easy way,
18
- to do the classic way of daemonise your awsome app?
19
- There will be no problem at all, let the Ogre do the job!
20
-
21
- so all you need is enjoy your code!
22
- Follow me on Github and send request,
23
- if you have idea what can be usefull in creating your app :)
24
-
25
-
26
-
27
- Installation
28
- ------------
29
-
30
- ### [RubyGems](http://rubygems.org/)
31
-
32
- $ gem install 'daemon-ogre'
33
-
34
-
35
- require 'daemon-ogre'
36
- DaemonOgre.start
37
-
38
-
39
- but we love config our beloved App!
40
- -----------------------------------
41
-
42
-
43
- DaemonOgre.start :name => "MySuperAppName!", #this will be the name of the application
44
- :log_path => "./var/log/log_file_name", #this will be the logfile place and name
45
- :pid_path => "./var/pid/pid_file_name", #this will be the pidfile place and name
46
- :terminate => true #this command not let start your code if it's not started
47
- # with "start" arguments like :
48
- # ruby my_awsome_app.rb start
49
-
50
-
51
- In use?
52
- -------
53
-
54
-
55
- you can simply use your terminal with arguments like
56
- * start - for start the process if you choosed :terminate => true in code like above
57
- start command will check does the application already running or not, so you dont have to worry about
58
-
59
- * stop - will terminate the running application
60
- * restart - will stop the process if that is already running than start again
61
- * debug or -d - this will show the fancy loadings if you want look busy by coding big stuffs :) (or debug your code)
62
- * debugger - this will call the ruby debugger gem to aid you in trouble
63
- you should use these commands:
64
-
65
-
66
- set autolist on #show the code, and the position like and editor, in every step.
67
- s #step in any kind of method, beware to use carefully because you end up in really deep somewhere in Alice world
68
- n #step to next code/codeblock etc, without enter it (usefull when you find the right place)
69
- l #list your current position
70
- #simply hit enter to repeate the last one
71
-
72
-
73
- * daemon -this will fork a child process by the given parameters
74
- * log or -l -you can set the log file position n by terminal for one time run
75
- * pid or -p -you can set the pid file position n name by terminal for one time run
76
- * status or -s -this will tell you ,does your process is running not
77
- * help -this will invoke some help to the terminal if you out of luck and forget everything from this page
78
- * clear -this will remove every log by the prev given paths, usefull in debugging
79
-
80
- example:
81
-
82
- ruby my_awsome_app.rb start debugger
83
- ruby my_awsome_app.rb start clear
84
- ruby my_awsome_app.rb status
85
- ruby my_awsome_app.rb stop
86
- ruby my_awsome_app.rb debug
87
-
88
-
89
- or if you dont use terminate command , than you can start simply as how you do normaly
90
-
91
-
92
-
93
- othere stuffs to use:
94
- ---------------------
95
- everybody love: require_relative...
96
- so why should not try require_directory instead all the fuss
97
- you can tell to it if you want some file to be excluded or just delayed loaded,
98
- because you want them loaded in the last place
99
- Example:
100
-
101
-
102
- require_directory "some_dir_name_from_here_where_are_multi_dir_levels"
103
-
104
- or
105
-
106
- require_directory "some_dir_name_from_here_where_are_multi_dir_levels",
107
- :delay => ["files","to","be","delayed","in","load"],
108
- :exclude => ["files","to","be","excluded","in","load"],
109
- :type => "rb"
110
-
111
- remember, you can use any of those modifier hash-tag by it self only! :)
112
- by default the type will be .rb files
113
-
114
-
115
- Helpers
116
- -------
117
-
118
- and ofc what else what we love if not our beloved yml-s
119
- we should use a nice Config constant for this(or at least i love to do)
120
-
121
- CONFIG = require_ymls "some_dir_name_from_here_where_are_the_yml_files_in_multi_dir_level"
122
-
123
- the file names will be the hash-key and under that , there will be the yml file datas loaded in
124
-
125
- And if we are at hashs, than when you need remove an element perm, or not perm you can use
126
- * remove will return the hash w/o the the key
127
- * remove! will delete the key, than return the hash
128
- example:
129
-
130
- CONFIG.remove key
131
- CONFIG.remove! key
132
-
133
-
134
-
135
-
136
-
137
- if you need get a free port in a range or from, you can use this:
138
-
139
- get_port(from_nmb,to_nmb,host)
140
-
141
- or by simply
142
-
143
- get_port(number)
144
-
145
-
146
- and if you hate find all the bugs... you can use error_logger at your command like this if you running your process on
147
- background and cannot puts on the terminal:
148
-
149
-
150
- exlogger msg, #anything after this is optionable
151
- :path => "./per_relative-absoluth_path",
152
- :prefix => "it's something..."
153
-
154
-
155
- or with less fuss at the exception handle:
156
-
157
-
158
- begin
159
-
160
- rescue Exception => ex
161
- ex.logger
162
- end
163
-
164
-
165
- or the better way to do Exception handle is to rescue only those exceptions what we are know will be raised! so the app broke if something unexpected stupp come up! (development:)
166
-
167
-
168
- begin
169
- raise ArgumentError, "failed"
170
- rescue ArgumentError => ex
171
- ex.logger
172
- end
173
-
174
-
175
-
176
-
177
- if you need methods from any kind of class without the object methods, you should try this!
178
-
179
-
180
- Xyclassname.class_methods
181
-
182
-
183
- you want make some test script with rnd numbers, strings, dates, bools etc? use the Rnd class at your command
184
-
185
-
186
- Rnd
187
- -string
188
- -integer
189
- -boolean
190
- -date
191
-
192
-
193
- examples:
194
-
195
-
196
- Rnd.number(100)
197
- Rnd.string(15,2) #for rnd bla bla names
198
-
199
-
200
-
201
- You need get the index of an Array element? you can use:
202
-
203
-
204
-
205
- array_variable.index_of("something)
206
-
207
-
208
- Do you wanted to know , does that process running on that pid or not?
209
-
210
-
211
-
212
- process_running?(nmbr)
213
-
214
-
215
-
216
-
217
- in Short:
218
- ---------
219
-
220
- require 'daemon-ogre'
221
- DaemonOgre.start
222
- your_Super_app_code!
223
-
224
-
225
-
226
-
227
-
228
- Contributing to daemon-ogre
229
- ---------------------------
230
-
231
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
232
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
233
- * Fork the project.
234
- * Start a feature/bugfix branch.
235
- * Commit and push until you are happy with your contribution.
236
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
237
- * 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.
238
-
239
- Copyright
240
- ---------
241
-
242
- Right to copy and use at your service fellow coder
243
- Copyright (c) 2013 adam.luzsi. See LICENSE.txt for
244
- further details.
245
-
246
-
247
- daemon-ogre