raad_totem 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +57 -7
- data/lib/raad_totem/runner.rb +0 -2
- data/lib/raad_totem/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b772d074bcc80584f4bb8f0bcb48b32521f04f84
|
4
|
+
data.tar.gz: 08a63c2fe519d1ec7d6002bc0e68be0027161862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca7a0a6f3d8dcbf1fce64706d9efed240d5b34565bdd4fca5a8caadb394453222a971e9d2a4f7e377b8a29161b42abe69842f348e9f4b2469918c5f6e40c188
|
7
|
+
data.tar.gz: 260c1543892a3d7d31d990352307d6faf2697afb5669a98076b31f3ee76dce3814c042aef5c02f940b056fa6e83fba39b4508f5b83116b3dcb6c21109bf2c35e
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -7,26 +7,76 @@ This is a fork of the [Raad](https://github.com/colinsurprenant/raad) gem that i
|
|
7
7
|
## Changes from the original Raad v0.5.0:
|
8
8
|
|
9
9
|
- Removal of log4j since Totem already has a built in logger.
|
10
|
-
- Integration with Totem
|
10
|
+
- Integration with Totem.
|
11
11
|
- Change namespaces so as not to conflict with Raad if both gems are installed.
|
12
|
+
- Removal of various command line options and use Totem defaults instead.
|
12
13
|
|
13
14
|
## Installation
|
14
15
|
|
15
|
-
Add this line to your
|
16
|
+
Add this line to your Totem project's Gemfile:
|
16
17
|
|
17
|
-
gem '
|
18
|
+
gem 'raad_totem', :require => 'raad_totem/shell_cmds/service'
|
18
19
|
|
19
20
|
And then execute:
|
20
21
|
|
21
22
|
$ bundle
|
22
23
|
|
23
|
-
|
24
|
+
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
Create a new service file `service/hello_world_service.rb` in the project root directory:
|
26
27
|
|
27
|
-
|
28
|
+
#!/usr/bin/env ruby
|
29
|
+
|
30
|
+
require_relative '../config/environment.rb'
|
31
|
+
|
32
|
+
require 'raad_totem'
|
33
|
+
|
34
|
+
class HelloWorldService
|
35
|
+
def self.options_parser(parser, options)
|
36
|
+
parser.separator('')
|
37
|
+
parser.separator('App Options:')
|
38
|
+
|
39
|
+
parser.on('-c', '--custom', 'Some custom option') {|val| options[:custom] = val }
|
40
|
+
|
41
|
+
return parser
|
42
|
+
end
|
43
|
+
|
44
|
+
def start
|
45
|
+
Totem.logger.info('Service start.')
|
46
|
+
|
47
|
+
while !RaadTotem.stopped?
|
48
|
+
Totem.logger.info('Hello World.')
|
49
|
+
sleep 5
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def stop
|
54
|
+
Totem.logger.info('Service stop.')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Make sure you set executable permissions on your service file:
|
59
|
+
|
60
|
+
chmod +x service/hello_world_service.rb
|
61
|
+
|
62
|
+
You can run your service in the foreground (press ctrl+c to kill it and wait a few seconds):
|
63
|
+
|
64
|
+
./service/hello_world_service.rb start
|
65
|
+
|
66
|
+
You can also run your service in the background:
|
67
|
+
|
68
|
+
./service/hello_world_service.rb -d start
|
69
|
+
|
70
|
+
To stop the background service:
|
71
|
+
|
72
|
+
./service/hello_world_service.rb stop
|
73
|
+
|
74
|
+
By default, your service will log to a custom log in the `log` directory.
|
75
|
+
It will also create a PID file in the `tmp/pid` directory.
|
76
|
+
|
77
|
+
To view all available options (including custom ones you define):
|
28
78
|
|
29
|
-
|
79
|
+
./service/hello_world_service.rb --help
|
30
80
|
|
31
81
|
## Contributing
|
32
82
|
|
data/lib/raad_totem/runner.rb
CHANGED
@@ -170,8 +170,6 @@ module RaadTotem
|
|
170
170
|
opts.separator "Service Options:"
|
171
171
|
|
172
172
|
opts.on('-d', '--daemonize', "run daemonized in the background (default: no)") { |v| @parsed_options[:daemonize] = v }
|
173
|
-
opts.on('-P', '--pid FILE', "pid file when daemonized (default: tmp/pids directory)") { |file| @parsed_options[:pid_file] = file }
|
174
|
-
opts.on('-r', '--redirect FILE', "redirect stdout when daemonized (default: log directory)") { |v| @parsed_options[:redirect] = v }
|
175
173
|
opts.on('-e', '--environment ENVIRONMENT', "Totem environment") { |v| Totem.env = v }
|
176
174
|
opts.on('-i', '--instance INSTANCE', "Totem instance") { |v| Totem.instance = v }
|
177
175
|
opts.on(nil, '--timeout SECONDS', "seconds to wait before force stopping the service (default: 60)") { |v| @parsed_options[:stop_timeout] = v }
|
data/lib/raad_totem/version.rb
CHANGED