serf-td-agent 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06034a5521174e358ee6c051be92bf27f013ab39
4
+ data.tar.gz: 0cf3acd76461f7941f4f95a7c2cb513c42c9b7e0
5
+ SHA512:
6
+ metadata.gz: 9e88b9a490c8161935e59c26d216bbb00dd8efc9320c20226d2661fdbd10d3a9ed902bbdea98da65e4a0116e2aa045cdd16b14b81e55b8676c8b4905538b9597
7
+ data.tar.gz: 5c3acdd9d6513b4f6b816647b86ff3237f91639b9dfb061964265c329a468219f7c92ba05130c18eaf098aa73a68bd0b0236d6ef6b46184ee253d49f119a79d5
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ Makefile
3
+ *.zip
4
+ tmp/*
5
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (2014/05/19)
2
+
3
+ First version
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+ gem 'pry'
5
+ gem 'pry-nav'
6
+ gem 'gem-open'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Naotoshi Seo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,79 @@
1
+ # serf-td-agent
2
+
3
+ td-agent process management with [serf](http://www.serfdom.io/)
4
+
5
+ ## Installation
6
+
7
+ Use RubyGems:
8
+
9
+ ```
10
+ gem install serf-td-agent
11
+ ```
12
+
13
+ The `serf` command is automatically downloaded and bundled into the `bin` directory. Set the environment variable `PATH` as:
14
+
15
+ ```
16
+ export PATH=$(gem path serf-td-agent)/bin:$PATH
17
+ ```
18
+
19
+ ## How to setup the serf cluster
20
+
21
+ Run the first serf at any of hosts to run td-agent like:
22
+
23
+ ```bash
24
+ $ serf agent -event-handler=serf-td-agent
25
+ ```
26
+
27
+ Run later serfs at other hosts to run td-agent like:
28
+
29
+ ```bash
30
+ $ serf agent -join=${the first serf address} -event-handler=serf-td-agent
31
+ ```
32
+
33
+ Hint: `-log-level=debug` option should be helpful for debugging.
34
+
35
+ ## How to start td-agent via serf
36
+
37
+ Send a serf event from any of hosts running the serf like:
38
+
39
+ ```bash
40
+ $ serf event td-agent-start
41
+ ```
42
+
43
+ This will propagate the `start` event to the entire serf cluster and execute `sudo /etc/init.d/td-agent start` at all hosts.
44
+
45
+ ## Available events
46
+
47
+ Following events are available:
48
+
49
+ * `td-agent-start`
50
+ * `td-agent-stop`
51
+ * `td-agent-reload`
52
+ * `td-agent-restart`
53
+ * `td-agent-condrestart`
54
+ * `td-agent-status`
55
+ * `td-agent-configtest`
56
+
57
+ which corresponds with /etc/init.d/td-agent command.
58
+
59
+ ## ToDo
60
+
61
+ Use `serf query` for commands which requires responses like `status` and `configtest`.
62
+
63
+ ## ChangeLog
64
+
65
+ See [CHANGELOG.md](CHANGELOG.md) for details.
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create new [Pull Request](../../pull/new/master)
74
+
75
+ ## Copyright
76
+
77
+ Copyright (c) 2014 Naotoshi Seo. See [LICENSE](LICENSE) for details.
78
+
79
+ The license of `serf` belongs to serf. See [serf/LICENSE](https://github.com/hashicorp/serf/blob/master/LICENSE).
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ INIT_SCRIPT = "/etc/init.d/td-agent"
4
+ event = ENV['SERF_EVENT']
5
+ user_event = ENV['SERF_USER_EVENT']
6
+ td_agent_event = user_event[9..-1] if user_event and user_event.start_with?('td-agent-')
7
+
8
+ if ARGV[0] == "-h"
9
+ puts "Usage: SERF_EVENT=user SERF_USER_EVENT={event} #{$PROGRAM_NAME}"
10
+ puts ""
11
+ puts "AVAILABLE EVENTS:"
12
+ puts " td-agent-start"
13
+ puts " td-agent-stop"
14
+ puts " td-agent-reload"
15
+ puts " td-agent-restart"
16
+ puts " td-agent-condrestart"
17
+ puts " td-agent-status"
18
+ puts " td-agent-configtest"
19
+ puts ""
20
+ puts "WITH SERF:"
21
+ puts " serf event {event}"
22
+ exit 0
23
+ end
24
+
25
+ status = 0
26
+ case event
27
+ when "user"
28
+ case td_agent_event
29
+ when "start", "stop", "reload", "restart", "condrestart", "status", "configtest"
30
+ status = system "sudo #{INIT_SCRIPT} #{td_agent_event}"
31
+ end
32
+ end
33
+ exit status
@@ -0,0 +1,32 @@
1
+ require 'mkmf'
2
+ # I actually do not need this, but it looks gem install requires Makefile anyway
3
+ create_makefile('serf-td-agent')
4
+
5
+ # curl --insecure --silent -L -O https://dl.bintray.com/mitchellh/serf/0.6.0_linux_amd64.zip
6
+ CURL_CMD="curl --insecure --silent -L -O"
7
+ SERF_BASEURI="https://dl.bintray.com/mitchellh/serf"
8
+ SERF_VERSION="0.6.0"
9
+
10
+ os, arch = nil, nil
11
+ case RUBY_PLATFORM
12
+ when /linux/
13
+ os = 'linux'
14
+ when /darwin/
15
+ os = 'darwon'
16
+ when /mingw|win32/
17
+ os = 'windows'
18
+ when /freebsd/
19
+ os = 'freebsd'
20
+ end
21
+ case RUBY_PLATFORM
22
+ when /i386|i686/
23
+ arch = '386'
24
+ when /x86_64|amd64/
25
+ arch = 'amd64'
26
+ when /arm/
27
+ arch = 'arm'
28
+ end
29
+
30
+ zip_filename = "#{SERF_VERSION}_#{os}_#{arch}.zip"
31
+ system "#{CURL_CMD} #{SERF_BASEURI}/#{zip_filename}"
32
+ system "unzip #{zip_filename} -d #{File.expand_path('../../../bin', __FILE__)}"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "serf-td-agent"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Naotoshi Seo"]
8
+ s.email = ["sonots@gmail.com"]
9
+ s.homepage = "http://github.com/sonots/serf-td-agent"
10
+ s.summary = "A td-agent process management with serf"
11
+ s.description = s.summary
12
+ s.extensions = ["ext/serf-td-agent/extconf.rb"]
13
+ s.licenses = ["MIT"]
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency "gem-path", '~> 0'
21
+ s.add_development_dependency "rake"
22
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: serf-td-agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem-path
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A td-agent process management with serf
42
+ email:
43
+ - sonots@gmail.com
44
+ executables:
45
+ - serf-td-agent
46
+ extensions:
47
+ - ext/serf-td-agent/extconf.rb
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - CHANGELOG.md
52
+ - Gemfile
53
+ - LICENSE
54
+ - README.md
55
+ - Rakefile
56
+ - bin/serf-td-agent
57
+ - ext/serf-td-agent/extconf.rb
58
+ - serf-td-agent.gemspec
59
+ homepage: http://github.com/sonots/serf-td-agent
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A td-agent process management with serf
83
+ test_files: []