foreverb 0.3.0.d → 0.3.0.e
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +2 -0
- data/README.md +56 -0
- data/bin/foreverb +37 -9
- data/lib/forever/base.rb +15 -0
- data/lib/forever/version.rb +1 -1
- metadata +4 -4
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -374,6 +374,62 @@ end
|
|
374
374
|
Process.waitall
|
375
375
|
```
|
376
376
|
|
377
|
+
## /etc/init.d script sample
|
378
|
+
|
379
|
+
Use the following script if you want **foreverb** to fire up all of your daemons at boot time in Linux:
|
380
|
+
|
381
|
+
```#!/bin/sh
|
382
|
+
### BEGIN INIT INFO
|
383
|
+
# Provides: foreverb
|
384
|
+
# Required-Start: $local_fs $remote_fs
|
385
|
+
# Required-Stop: $local_fs $remote_fs
|
386
|
+
# Default-Start: 2 3 4 5
|
387
|
+
# Default-Stop: S 0 1 6
|
388
|
+
# Short-Description: foreverb initscript
|
389
|
+
# Description: foreverb
|
390
|
+
### END INIT INFO
|
391
|
+
|
392
|
+
# Do NOT "set -e"
|
393
|
+
|
394
|
+
DAEMON="foreverb"
|
395
|
+
USER="username"
|
396
|
+
SCRIPT_NAME="/etc/init.d/foreverb-username"
|
397
|
+
|
398
|
+
case "$1" in
|
399
|
+
start)
|
400
|
+
su -l $USER -c "$DAEMON start --all --yes"
|
401
|
+
;;
|
402
|
+
stop)
|
403
|
+
su -l $USER -c "$DAEMON stop --all --yes"
|
404
|
+
;;
|
405
|
+
restart)
|
406
|
+
su -l $USER -c "$DAEMON restart --all --yes"
|
407
|
+
;;
|
408
|
+
*)
|
409
|
+
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
|
410
|
+
exit 3
|
411
|
+
;;
|
412
|
+
esac
|
413
|
+
|
414
|
+
:
|
415
|
+
```
|
416
|
+
|
417
|
+
You'll have to create one script per each user foreverb runs on.
|
418
|
+
After creating the file, make it executable:
|
419
|
+
```chmod +x /etc/init.d/foreverb-username
|
420
|
+
```
|
421
|
+
and add it to the system's boot:
|
422
|
+
|
423
|
+
* RedHat:
|
424
|
+
```sudo /sbin/chkconfig --level 345 foreverb-username on
|
425
|
+
```
|
426
|
+
* Debian/Ubuntu:
|
427
|
+
```sudo /usr/sbin/update-rc.d -f foreverb-username defaults
|
428
|
+
```
|
429
|
+
* Gentoo:
|
430
|
+
```sudo rc-update add foreverb-username default
|
431
|
+
```
|
432
|
+
|
377
433
|
## Extras
|
378
434
|
|
379
435
|
To see a most comprensive app running _foreverb_ + _growl_ see [githubwatcher gem](https://github.com/daddye/githubwatcher)
|
data/bin/foreverb
CHANGED
@@ -38,15 +38,7 @@ class CLI < Thor
|
|
38
38
|
method_option :yes, :type => :boolean, :aliases => "-y", :desc => "Don't ask permission to kill daemon"
|
39
39
|
def stop(daemon=nil)
|
40
40
|
find(daemon, :multiple => options.all).each do |conf|
|
41
|
-
if options.yes || yes?("Do you want really stop \e[1m#{conf[:file]}\e[0m?")
|
42
|
-
say_status "STOPPING", conf[:file]
|
43
|
-
begin
|
44
|
-
pid = File.read(conf[:pid]).to_i
|
45
|
-
Process.kill(:INT, pid)
|
46
|
-
rescue Exception => e
|
47
|
-
say_status "ERROR", e.message, :red
|
48
|
-
end
|
49
|
-
end
|
41
|
+
stop_daemon(conf) if options.yes || yes?("Do you want really stop \e[1m#{conf[:file]}\e[0m?")
|
50
42
|
end
|
51
43
|
end
|
52
44
|
|
@@ -103,6 +95,28 @@ class CLI < Thor
|
|
103
95
|
end
|
104
96
|
end
|
105
97
|
|
98
|
+
desc "remove [DAEMON] [--all]", "Remove the config of a daemon from foreverb"
|
99
|
+
method_option :all, :type => :boolean, :aliases => "-a", :desc => "All matching daemons"
|
100
|
+
method_option :yes, :type => :boolean, :aliases => "-y", :desc => "Don't ask permission to remove the daemon"
|
101
|
+
def remove(daemon=nil)
|
102
|
+
say "You must provide a daemon name or provide --all option", :red and return if daemon.nil? && !options.all
|
103
|
+
new_config = config.delete_if do |conf|
|
104
|
+
if conf[:file] =~ /#{daemon}/
|
105
|
+
if options.yes || yes?("Do you really want to remove the daemon \e[1m#{conf[:file]}\e[0m?")
|
106
|
+
stop_daemon(conf)
|
107
|
+
say "\e[1m#{conf[:file]}\e[0m removed."
|
108
|
+
true
|
109
|
+
else
|
110
|
+
say "\e[1m#{conf[:file]}\e[0m remains on the list."
|
111
|
+
false
|
112
|
+
end
|
113
|
+
else
|
114
|
+
false
|
115
|
+
end
|
116
|
+
end
|
117
|
+
write_config! new_config
|
118
|
+
end
|
119
|
+
|
106
120
|
map "--version" => :version
|
107
121
|
desc "version", "show the version number"
|
108
122
|
def version
|
@@ -136,6 +150,20 @@ class CLI < Thor
|
|
136
150
|
result.each { |column| column[2] = "%s %" % [column[2]] }
|
137
151
|
result
|
138
152
|
end
|
153
|
+
|
154
|
+
def write_config!(new_config)
|
155
|
+
File.open(FOREVER_PATH, "w") { |f| f.write new_config.to_yaml }
|
156
|
+
end
|
157
|
+
|
158
|
+
def stop_daemon(conf)
|
159
|
+
say_status "STOPPING", conf[:file]
|
160
|
+
begin
|
161
|
+
pid = File.read(conf[:pid]).to_i
|
162
|
+
Process.kill(:INT, pid)
|
163
|
+
rescue Exception => e
|
164
|
+
say_status "ERROR", e.message, :red
|
165
|
+
end
|
166
|
+
end
|
139
167
|
end
|
140
168
|
|
141
169
|
ARGV << "-h" if ARGV.empty?
|
data/lib/forever/base.rb
CHANGED
@@ -37,6 +37,10 @@ module Forever
|
|
37
37
|
when 'update'
|
38
38
|
print "[\e[90m%s\e[0m] Config written in \e[1m%s\e[0m\n" % [name, FOREVER_PATH]
|
39
39
|
exit
|
40
|
+
when 'remove'
|
41
|
+
stop
|
42
|
+
remove
|
43
|
+
exit
|
40
44
|
else
|
41
45
|
print <<-RUBY.gsub(/ {10}/,'') % name
|
42
46
|
Usage: \e[1m./%s\e[0m [start|stop|kill|restart|config|update]
|
@@ -49,6 +53,7 @@ module Forever
|
|
49
53
|
kill force stop by sending a KILL signal to the process
|
50
54
|
config show the current daemons config
|
51
55
|
update update the daemon config
|
56
|
+
remove removes the daemon config
|
52
57
|
|
53
58
|
RUBY
|
54
59
|
exit
|
@@ -223,6 +228,16 @@ module Forever
|
|
223
228
|
end
|
224
229
|
end
|
225
230
|
|
231
|
+
##
|
232
|
+
# Remove the daemon from the config file
|
233
|
+
#
|
234
|
+
def remove
|
235
|
+
print "[\e[90m%s\e[0m] Removed the daemon from the config " % name
|
236
|
+
config_was = File.exist?(FOREVER_PATH) ? YAML.load_file(FOREVER_PATH) : []
|
237
|
+
config_was.delete_if { |conf| conf[:file] == file }
|
238
|
+
File.open(FOREVER_PATH, "w") { |f| f.write config_was.to_yaml }
|
239
|
+
end
|
240
|
+
|
226
241
|
##
|
227
242
|
# Callback raised when an error occour
|
228
243
|
#
|
data/lib/forever/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreverb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.3.0.
|
10
|
+
- e
|
11
|
+
version: 0.3.0.e
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- DAddYE
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-10-
|
19
|
+
date: 2011-10-14 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|