filbunke 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/bin/filbunked +7 -2
- data/doc/examples/filbunke_config.yml +2 -2
- data/doc/examples/init_script +75 -0
- data/filbunke.gemspec +2 -4
- data/lib/filbunke/client.rb +21 -18
- data/lib/filbunke/daemon.rb +1 -1
- metadata +3 -16
data/Rakefile
CHANGED
@@ -12,7 +12,6 @@ begin
|
|
12
12
|
gem.authors = ["Wouter de Bie"]
|
13
13
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
14
|
gem.files.exclude 'pkg'
|
15
|
-
gem.add_dependency 'activesupport', '>= 2.1.0'
|
16
15
|
gem.executables = ['filbunked']
|
17
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
17
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.4
|
data/bin/filbunked
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
$0=File.join(File.dirname(__FILE__), 'filbunked')
|
3
3
|
require 'rubygems'
|
4
4
|
require 'filbunke'
|
5
5
|
require 'yaml'
|
@@ -15,7 +15,12 @@ raw_opts.each do |opt, arg|
|
|
15
15
|
opts[opt] = arg
|
16
16
|
end
|
17
17
|
|
18
|
-
if
|
18
|
+
if Process.uid != 0 then
|
19
|
+
puts "Filbunke should be started as root!"
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
|
23
|
+
if opts['--help'] || opts['--config'] == nil || opts['--config'] == ""
|
19
24
|
puts "Usage: filbunked -c <config_file.yml>"
|
20
25
|
exit 1
|
21
26
|
else
|
@@ -1,10 +1,10 @@
|
|
1
1
|
---
|
2
2
|
pid_file: '/var/run/filbunked.pid'
|
3
|
-
user: '
|
3
|
+
user: 'wouter'
|
4
4
|
log_file: '/tmp/filbunke.log'
|
5
5
|
checkpoint_path: '/var/tmp/filbunke_checkpoints/'
|
6
6
|
run_every: 5
|
7
|
-
callback_path: '/
|
7
|
+
callback_path: '/Users/wouter/prjs/filbunke-cdn/client/doc/examples'
|
8
8
|
repositories:
|
9
9
|
cache:
|
10
10
|
local_path: '/v5/cachetest'
|
@@ -0,0 +1,75 @@
|
|
1
|
+
### BEGIN INIT INFO
|
2
|
+
# Provides: filbunked
|
3
|
+
# Required-Start: $all
|
4
|
+
# Required-Stop: $all
|
5
|
+
# Default-Start: 2 3 4 5
|
6
|
+
# Default-Stop: 0 1 6
|
7
|
+
# Short-Description: starts the trinidad server
|
8
|
+
# Description: starts trinidad using start-stop-daemon
|
9
|
+
### END INIT INFO
|
10
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
11
|
+
DAEMON="/var/lib/gems/1.8/bin/filbunked"
|
12
|
+
DAEMON_OPTS="-c /etc/filbunke/filbunke_config.yml"
|
13
|
+
NAME=filbunked
|
14
|
+
DESC=filbunked
|
15
|
+
|
16
|
+
test -x $DAEMON || exit 0
|
17
|
+
|
18
|
+
set -e
|
19
|
+
|
20
|
+
. /lib/lsb/init-functions
|
21
|
+
|
22
|
+
start(){
|
23
|
+
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
|
24
|
+
--exec $DAEMON -- $DAEMON_OPTS || true
|
25
|
+
}
|
26
|
+
|
27
|
+
stop(){
|
28
|
+
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid || true
|
29
|
+
}
|
30
|
+
|
31
|
+
force_stop(){
|
32
|
+
stop
|
33
|
+
}
|
34
|
+
|
35
|
+
force_restart(){
|
36
|
+
force_stop
|
37
|
+
sleep 2
|
38
|
+
start
|
39
|
+
}
|
40
|
+
|
41
|
+
case "$1" in
|
42
|
+
start)
|
43
|
+
echo -n "Starting $DESC: "
|
44
|
+
start
|
45
|
+
echo "$NAME."
|
46
|
+
;;
|
47
|
+
stop)
|
48
|
+
echo -n "Stopping $DESC: "
|
49
|
+
stop
|
50
|
+
echo "$NAME."
|
51
|
+
;;
|
52
|
+
force-stop)
|
53
|
+
echo -n "Stopping $DESC: "
|
54
|
+
force_stop
|
55
|
+
echo "$NAME."
|
56
|
+
;;
|
57
|
+
restart|reload)
|
58
|
+
echo -n "Restarting $DESC: "
|
59
|
+
force_restart
|
60
|
+
echo "$NAME."
|
61
|
+
force-restart)
|
62
|
+
echo -n "Restarting $DESC: "
|
63
|
+
force_restart
|
64
|
+
echo "$NAME."
|
65
|
+
;;
|
66
|
+
status)
|
67
|
+
status_of_proc -p /var/run/$NAME.pid "$DAEMON" $NAME && exit 0 || exit $?
|
68
|
+
;;
|
69
|
+
*)
|
70
|
+
echo "Usage: $NAME {start|stop|restart|reload|force-restart|force-stop|status}" >&2
|
71
|
+
exit 1
|
72
|
+
;;
|
73
|
+
esac
|
74
|
+
|
75
|
+
exit 0
|
data/filbunke.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{filbunke}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Wouter de Bie"]
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"bin/filbunked",
|
24
24
|
"doc/examples/filbunke_config.yml",
|
25
25
|
"doc/examples/http_evict_cache.rb",
|
26
|
+
"doc/examples/init_script",
|
26
27
|
"filbunke.gemspec",
|
27
28
|
"lib/filbunke.rb",
|
28
29
|
"lib/filbunke/callbacks.rb",
|
@@ -46,14 +47,11 @@ Gem::Specification.new do |s|
|
|
46
47
|
|
47
48
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
49
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
49
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 2.1.0"])
|
50
50
|
else
|
51
51
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
52
|
-
s.add_dependency(%q<activesupport>, [">= 2.1.0"])
|
53
52
|
end
|
54
53
|
else
|
55
54
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
56
|
-
s.add_dependency(%q<activesupport>, [">= 2.1.0"])
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
data/lib/filbunke/client.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
require 'active_support/all' rescue nil
|
3
1
|
require 'json'
|
4
2
|
require 'net/http'
|
5
3
|
require 'fileutils'
|
@@ -27,7 +25,7 @@ module Filbunke
|
|
27
25
|
failure = false
|
28
26
|
updated_files.each do |raw_file|
|
29
27
|
file = File.new(raw_file)
|
30
|
-
if file.url
|
28
|
+
if file.url =~ /^http:\/\//
|
31
29
|
local_file_path = ::File.join(repository.local_path, file.path)
|
32
30
|
if update_http_file!(file, local_file_path) then
|
33
31
|
@callbacks.each do |callback|
|
@@ -77,22 +75,27 @@ module Filbunke
|
|
77
75
|
private
|
78
76
|
|
79
77
|
def get_updated_file_list(last_checkpoint)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
78
|
+
begin
|
79
|
+
updates_http = Net::HTTP.new(@repository.host, @repository.port)
|
80
|
+
updates_http.start do |http|
|
81
|
+
begin
|
82
|
+
updates_path = "/#{UPDATES_ACTION}/#{@repository.name}?#{FROM_CHECKPOINT_KEY}=#{last_checkpoint}"
|
83
|
+
request = Net::HTTP::Get.new(updates_path)
|
84
|
+
response = http.request(request)
|
85
|
+
if response.code.to_i == 200
|
86
|
+
JSON.parse(response.body)
|
87
|
+
else
|
88
|
+
@logger.log "Failed to download updates for #{@repository.name}, error code = #{response.code}"
|
89
|
+
end
|
90
|
+
rescue StandardError => e
|
91
|
+
@logger.log "Error getting file list: #{e.message}! Retrying later.."
|
92
|
+
{}
|
93
|
+
end
|
94
94
|
end
|
95
|
-
|
95
|
+
rescue StandardError => e
|
96
|
+
@logger.log "Unable to create HTTP connection to #{@repository.host}:#{@repository.port} (#{e.message})!"
|
97
|
+
return {}
|
98
|
+
end
|
96
99
|
end
|
97
100
|
|
98
101
|
def update_http_file!(file, local_file_path)
|
data/lib/filbunke/daemon.rb
CHANGED
@@ -25,7 +25,7 @@ module Filbunke
|
|
25
25
|
callbacks = []
|
26
26
|
repository_config["callbacks"].each do |callback_name, callback_config|
|
27
27
|
require ::File.join(@config["callback_path"], callback_name.to_s)
|
28
|
-
callback_class =
|
28
|
+
callback_class = Module.const_get(callback_name.split("_").map(&:capitalize).join)
|
29
29
|
callbacks << callback_class.new(@logger, callback_config)
|
30
30
|
end
|
31
31
|
Client.new(repository, @logger, callbacks)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 4
|
9
|
+
version: 1.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Wouter de Bie
|
@@ -29,20 +29,6 @@ dependencies:
|
|
29
29
|
version: "0"
|
30
30
|
type: :development
|
31
31
|
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: activesupport
|
34
|
-
prerelease: false
|
35
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
segments:
|
40
|
-
- 2
|
41
|
-
- 1
|
42
|
-
- 0
|
43
|
-
version: 2.1.0
|
44
|
-
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
32
|
description: Filbunke client and library
|
47
33
|
email: wouter@deltaprojects.se
|
48
34
|
executables:
|
@@ -60,6 +46,7 @@ files:
|
|
60
46
|
- bin/filbunked
|
61
47
|
- doc/examples/filbunke_config.yml
|
62
48
|
- doc/examples/http_evict_cache.rb
|
49
|
+
- doc/examples/init_script
|
63
50
|
- filbunke.gemspec
|
64
51
|
- lib/filbunke.rb
|
65
52
|
- lib/filbunke/callbacks.rb
|