slnky 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/slnky +7 -0
- data/lib/capistrano/slnky.rb +1 -0
- data/lib/capistrano/tasks/slnky.rake +31 -0
- data/lib/slnky.rb +10 -0
- data/lib/slnky/cli.rb +30 -0
- data/lib/slnky/cli/generate.rb +18 -0
- data/lib/slnky/ext/deep_struct.rb +22 -0
- data/lib/slnky/generator.rb +51 -0
- data/lib/slnky/generator/command.rb +7 -0
- data/lib/slnky/generator/service.rb +7 -0
- data/lib/slnky/message.rb +16 -0
- data/lib/slnky/service.rb +93 -0
- data/lib/slnky/template/service/.env.sample +2 -0
- data/lib/slnky/template/service/.gitignore +10 -0
- data/lib/slnky/template/service/.rspec +2 -0
- data/lib/slnky/template/service/.travis.yml +4 -0
- data/lib/slnky/template/service/CODE_OF_CONDUCT.md +49 -0
- data/lib/slnky/template/service/Capfile +28 -0
- data/lib/slnky/template/service/Gemfile +12 -0
- data/lib/slnky/template/service/config/deploy.rb.erb +48 -0
- data/lib/slnky/template/service/config/deploy/production.rb +61 -0
- data/lib/slnky/template/service/config/deploy/staging.rb +61 -0
- data/lib/slnky/template/service/lib/capistrano/tasks/NAME.rake.erb +5 -0
- data/lib/slnky/template/service/lib/slnky/service/NAME.rb.erb +15 -0
- data/lib/slnky/template/service/service.erb +16 -0
- data/lib/slnky/template/service/spec/slnky/service/NAME_spec.rb.erb +7 -0
- data/lib/slnky/template/service/spec/spec_helper.rb.erb +2 -0
- data/lib/slnky/template/service/upstart/init.conf.erb +6 -0
- data/lib/slnky/version.rb +3 -0
- data/slnky.gemspec +39 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a6bd6848fc10306104ce788cbfd1058d19ad4a75
|
4
|
+
data.tar.gz: b2ea1538b1bb204a804b48d2f2f820e7591c412b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ccb792fa2a2e4d0ac6676e9d5a13f40b092a9a48db46b92fc14c5e06d717f45c66098189d27c35f1dbe6d4da1b0c7da7289c08e22538f7ea512ca7119032a2ab
|
7
|
+
data.tar.gz: b727a3db2d182091b193752ed270150d8a20511d7233738b8485d5e9cf94f6392dd43fc1b98f35b1e549bfbbb8e439b417a9053d0da9d87ff0612385864d82f3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at me@shawncatz.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Shawn Catanzarite
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Slnky::Service
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/slnky/service`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'slnky-service'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install slnky-service
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/slnky-service. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/slnky
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../tasks/slnky.rake", __FILE__)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
set :slnky_service, ->{ "slnky_#{fetch(:application)}_#{fetch(:stage)}" }
|
4
|
+
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :slnky do
|
9
|
+
desc 'upload local upstart config from upstart/init.conf'
|
10
|
+
task :config do
|
11
|
+
upload! "upstart/init.conf", "/etc/init.d/#{slnky_service}.conf"
|
12
|
+
end
|
13
|
+
|
14
|
+
[:start, :stop, :restart].each do |command|
|
15
|
+
desc "#{command} slnky service"
|
16
|
+
task command do
|
17
|
+
on roles :app do
|
18
|
+
sudo 'service', fetch(:slnky_service), command
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'setup task'
|
25
|
+
task :setup do
|
26
|
+
invoke 'slnky:config'
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :deploy do
|
30
|
+
after :publishing, 'slnky:restart'
|
31
|
+
end
|
data/lib/slnky.rb
ADDED
data/lib/slnky/cli.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'slnky'
|
2
|
+
require 'yaml'
|
3
|
+
require 'thor'
|
4
|
+
require 'active_support/all'
|
5
|
+
|
6
|
+
path = File.expand_path("../cli", __FILE__)
|
7
|
+
Dir["#{path}/**/*.rb"].each do |file|
|
8
|
+
require file
|
9
|
+
end
|
10
|
+
|
11
|
+
module Slnky
|
12
|
+
module CLI
|
13
|
+
class Main < Thor
|
14
|
+
desc 'init', 'initialize configuration directory'
|
15
|
+
def init
|
16
|
+
dir = "#{ENV['HOME']}/.slnky"
|
17
|
+
FileUtils.mkdir_p(dir)
|
18
|
+
defaults = {
|
19
|
+
slnky: {
|
20
|
+
url: 'http://localhost:3000'
|
21
|
+
}
|
22
|
+
}.deep_stringify_keys
|
23
|
+
File.open("#{dir}/config.yaml", "w+") {|f| f.write(defaults.to_yaml)}
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'generate', 'generate slnky objects from templates'
|
27
|
+
subcommand 'generate', Slnky::CLI::Generate
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Slnky
|
2
|
+
module CLI
|
3
|
+
class Generate < Thor
|
4
|
+
desc 'service NAME [DIR]', 'generate a service named NAME'
|
5
|
+
def service(name, dir=nil)
|
6
|
+
generator = Slnky::Generator::Service.new(name, dir)
|
7
|
+
raise Thor::Error, "error: directory '#{generator.dir}' exists" if File.exists?(generator.dir)
|
8
|
+
generator.generate
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'command NAME [DIR]', 'generate a service named NAME'
|
12
|
+
def command(name, dir=nil)
|
13
|
+
raise Thor::Error, "not implemented"
|
14
|
+
# Slnky::Generator::Command.new(name, dir).generate
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class DeepStruct < OpenStruct
|
4
|
+
def initialize(hash=nil)
|
5
|
+
@table = {}
|
6
|
+
@hash_table = {}
|
7
|
+
|
8
|
+
if hash
|
9
|
+
hash.each do |k,v|
|
10
|
+
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
|
11
|
+
@hash_table[k.to_sym] = v
|
12
|
+
|
13
|
+
new_ostruct_member(k)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_h
|
19
|
+
@hash_table
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'tilt'
|
3
|
+
|
4
|
+
module Slnky
|
5
|
+
module Generator
|
6
|
+
class Base
|
7
|
+
attr_reader :name
|
8
|
+
attr_reader :dir
|
9
|
+
|
10
|
+
def initialize(name, dir)
|
11
|
+
@name = name
|
12
|
+
@dir = dir == nil ? "slnky-#{name}" : dir
|
13
|
+
short = self.class.name.split('::').last.downcase
|
14
|
+
@template = File.expand_path("../template/#{short}", __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate
|
18
|
+
# copy dir
|
19
|
+
puts "creating directory and processing templates..."
|
20
|
+
FileUtils.cp_r(@template, @dir)
|
21
|
+
puts "#{@dir}:"
|
22
|
+
# process templates
|
23
|
+
Dir["#{@dir}/**/*"].each do |f|
|
24
|
+
next unless File.file?(f) && File.extname(f) == '.erb'
|
25
|
+
template(f)
|
26
|
+
end
|
27
|
+
# git init
|
28
|
+
puts "initializing git..."
|
29
|
+
`cd #{@dir} && git init . || true`
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def template(file)
|
35
|
+
var = {
|
36
|
+
name: @name,
|
37
|
+
dir: @dir
|
38
|
+
}
|
39
|
+
dest = file.gsub(/\.erb$/, '').gsub('NAME', @name)
|
40
|
+
puts " #{dest}"
|
41
|
+
template = Tilt.new(file)
|
42
|
+
output = template.render(self, var)
|
43
|
+
File.write(dest, output)
|
44
|
+
FileUtils.rm(file) if file != dest
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
require 'slnky/generator/command'
|
51
|
+
require 'slnky/generator/service'
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'slnky/version'
|
2
|
+
require 'slnky/message'
|
3
|
+
require 'amqp'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
module Slnky
|
7
|
+
module Service
|
8
|
+
class Base
|
9
|
+
def initialize(url)
|
10
|
+
@server = url
|
11
|
+
@name = self.class.name.split('::').last.downcase
|
12
|
+
@config = open("#{@server}/configs/#{@name}") {|f| f.read }
|
13
|
+
@host = @config['rabbit']['host']
|
14
|
+
@port = @config['rabbit']['port']
|
15
|
+
@subscriptions = {}
|
16
|
+
@periodics = []
|
17
|
+
@exchanges = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def start
|
21
|
+
AMQP.start("amqp://#{@host}:#{@port}") do |connection|
|
22
|
+
@channel = AMQP::Channel.new(connection)
|
23
|
+
@channel.on_error do |ch, channel_close|
|
24
|
+
raise "Channel-level exception: #{channel_close.reply_text}"
|
25
|
+
end
|
26
|
+
@exchanges['events'] = @channel.fanout("slnky.events")
|
27
|
+
@exchanges['logs'] = @channel.fanout("slnky.logs")
|
28
|
+
|
29
|
+
log :info, "slnky.service.#{@name}: running"
|
30
|
+
run
|
31
|
+
|
32
|
+
@channel.queue("service.events", durable: true).bind(@exchanges['events']).subscribe do |raw|
|
33
|
+
payload = parse(raw)
|
34
|
+
if @subscriptions[payload.name]
|
35
|
+
@subscriptions[payload.name].call(payload)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
@periodics.each do |p|
|
40
|
+
EventMachine.add_periodic_timer(p[:timer]) do
|
41
|
+
b = p[:block]
|
42
|
+
instance_eval &b
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
stopper = Proc.new do
|
47
|
+
puts 'stopping'
|
48
|
+
connection.close { EventMachine.stop }
|
49
|
+
end
|
50
|
+
|
51
|
+
Signal.trap("INT", stopper)
|
52
|
+
Signal.trap("TERM", stopper)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
protected
|
57
|
+
|
58
|
+
def run
|
59
|
+
# nothing here
|
60
|
+
end
|
61
|
+
|
62
|
+
def msg(data)
|
63
|
+
Slnky::Message.new(data)
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse(data)
|
67
|
+
Slnky::Message.parse(data)
|
68
|
+
end
|
69
|
+
|
70
|
+
def subscribe(name, &block)
|
71
|
+
@subscriptions[name] = block
|
72
|
+
end
|
73
|
+
|
74
|
+
def periodic(timer, &block)
|
75
|
+
@periodics << {timer: timer, block: block}
|
76
|
+
end
|
77
|
+
|
78
|
+
def log(level, message)
|
79
|
+
@exchanges['logs'].publish(msg({service: "#{@name}-#{$$}", level: level, message: message}))
|
80
|
+
end
|
81
|
+
|
82
|
+
# def pub(data)
|
83
|
+
# if block_given?
|
84
|
+
# @exchange.publish(msg(data)) do
|
85
|
+
# yield
|
86
|
+
# end
|
87
|
+
# else
|
88
|
+
# @exchange.publish(msg(data))
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at me@shawncatz.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Load DSL and set up stages
|
2
|
+
require 'capistrano/setup'
|
3
|
+
|
4
|
+
# Include default deployment tasks
|
5
|
+
require 'capistrano/deploy'
|
6
|
+
|
7
|
+
# Include tasks from other gems included in your Gemfile
|
8
|
+
#
|
9
|
+
# For documentation on these, see for example:
|
10
|
+
#
|
11
|
+
# https://github.com/capistrano/rvm
|
12
|
+
# https://github.com/capistrano/rbenv
|
13
|
+
# https://github.com/capistrano/chruby
|
14
|
+
# https://github.com/capistrano/bundler
|
15
|
+
# https://github.com/capistrano/rails
|
16
|
+
# https://github.com/capistrano/passenger
|
17
|
+
#
|
18
|
+
require 'capistrano/rvm'
|
19
|
+
# require 'capistrano/rbenv'
|
20
|
+
# require 'capistrano/chruby'
|
21
|
+
require 'capistrano/bundler'
|
22
|
+
# require 'capistrano/rails/assets'
|
23
|
+
# require 'capistrano/rails/migrations'
|
24
|
+
# require 'capistrano/passenger'
|
25
|
+
require 'capistrano/slnky'
|
26
|
+
|
27
|
+
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
|
28
|
+
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'slnky', github: 'shawncatz/slnky', branch: 'master'
|
4
|
+
gem 'daemons', '~> 1.2.3'
|
5
|
+
gem 'dotenv', '~> 2.1.0'
|
6
|
+
|
7
|
+
gem 'capistrano', '~> 3.4.0'
|
8
|
+
gem 'capistrano-rvm', '~> 0.1.2'
|
9
|
+
gem 'capistrano-bundler', '~> 1.1.4'
|
10
|
+
gem 'airbrussh', '~> 0.8.0'
|
11
|
+
|
12
|
+
gem 'rspec'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# config valid only for current version of Capistrano
|
2
|
+
lock '3.4.0'
|
3
|
+
|
4
|
+
set :application, '<%= dir %>'
|
5
|
+
set :repo_url, 'git@github.com:something/<%= dir %>.git'
|
6
|
+
|
7
|
+
# Default branch is :master
|
8
|
+
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
9
|
+
|
10
|
+
# Default deploy_to directory is /var/www/my_app_name
|
11
|
+
# set :deploy_to, '/var/www/my_app_name'
|
12
|
+
|
13
|
+
# Default value for :scm is :git
|
14
|
+
# set :scm, :git
|
15
|
+
|
16
|
+
# Default value for :format is :pretty
|
17
|
+
# set :format, :pretty
|
18
|
+
|
19
|
+
# Default value for :log_level is :debug
|
20
|
+
# set :log_level, :debug
|
21
|
+
|
22
|
+
# Default value for :pty is false
|
23
|
+
# set :pty, true
|
24
|
+
|
25
|
+
# Default value for :linked_files is []
|
26
|
+
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
|
27
|
+
|
28
|
+
# Default value for linked_dirs is []
|
29
|
+
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
|
30
|
+
|
31
|
+
# Default value for default_env is {}
|
32
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
33
|
+
|
34
|
+
# Default value for keep_releases is 5
|
35
|
+
# set :keep_releases, 5
|
36
|
+
|
37
|
+
namespace :deploy do
|
38
|
+
|
39
|
+
after :restart, :clear_cache do
|
40
|
+
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
41
|
+
# Here we can do anything such as:
|
42
|
+
# within release_path do
|
43
|
+
# execute :rake, 'cache:clear'
|
44
|
+
# end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# server-based syntax
|
2
|
+
# ======================
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
4
|
+
# You can define all roles on a single server, or split them:
|
5
|
+
|
6
|
+
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
7
|
+
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
8
|
+
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# role-based syntax
|
13
|
+
# ==================
|
14
|
+
|
15
|
+
# Defines a role with one or multiple servers. The primary server in each
|
16
|
+
# group is considered to be the first unless any hosts have the primary
|
17
|
+
# property set. Specify the username and a domain or IP for the server.
|
18
|
+
# Don't use `:all`, it's a meta role.
|
19
|
+
|
20
|
+
# role :app, %w{deploy@example.com}, my_property: :my_value
|
21
|
+
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
22
|
+
# role :db, %w{deploy@example.com}
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# Configuration
|
27
|
+
# =============
|
28
|
+
# You can set any configuration variable like in config/deploy.rb
|
29
|
+
# These variables are then only loaded and set in this stage.
|
30
|
+
# For available Capistrano configuration variables see the documentation page.
|
31
|
+
# http://capistranorb.com/documentation/getting-started/configuration/
|
32
|
+
# Feel free to add new variables to customise your setup.
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# Custom SSH Options
|
37
|
+
# ==================
|
38
|
+
# You may pass any option but keep in mind that net/ssh understands a
|
39
|
+
# limited set of options, consult the Net::SSH documentation.
|
40
|
+
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
41
|
+
#
|
42
|
+
# Global options
|
43
|
+
# --------------
|
44
|
+
# set :ssh_options, {
|
45
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
46
|
+
# forward_agent: false,
|
47
|
+
# auth_methods: %w(password)
|
48
|
+
# }
|
49
|
+
#
|
50
|
+
# The server-based syntax can be used to override options:
|
51
|
+
# ------------------------------------
|
52
|
+
# server 'example.com',
|
53
|
+
# user: 'user_name',
|
54
|
+
# roles: %w{web app},
|
55
|
+
# ssh_options: {
|
56
|
+
# user: 'user_name', # overrides user setting above
|
57
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
58
|
+
# forward_agent: false,
|
59
|
+
# auth_methods: %w(publickey password)
|
60
|
+
# # password: 'please use keys'
|
61
|
+
# }
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# server-based syntax
|
2
|
+
# ======================
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
4
|
+
# You can define all roles on a single server, or split them:
|
5
|
+
|
6
|
+
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
7
|
+
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
8
|
+
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# role-based syntax
|
13
|
+
# ==================
|
14
|
+
|
15
|
+
# Defines a role with one or multiple servers. The primary server in each
|
16
|
+
# group is considered to be the first unless any hosts have the primary
|
17
|
+
# property set. Specify the username and a domain or IP for the server.
|
18
|
+
# Don't use `:all`, it's a meta role.
|
19
|
+
|
20
|
+
# role :app, %w{deploy@example.com}, my_property: :my_value
|
21
|
+
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
22
|
+
# role :db, %w{deploy@example.com}
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# Configuration
|
27
|
+
# =============
|
28
|
+
# You can set any configuration variable like in config/deploy.rb
|
29
|
+
# These variables are then only loaded and set in this stage.
|
30
|
+
# For available Capistrano configuration variables see the documentation page.
|
31
|
+
# http://capistranorb.com/documentation/getting-started/configuration/
|
32
|
+
# Feel free to add new variables to customise your setup.
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# Custom SSH Options
|
37
|
+
# ==================
|
38
|
+
# You may pass any option but keep in mind that net/ssh understands a
|
39
|
+
# limited set of options, consult the Net::SSH documentation.
|
40
|
+
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
41
|
+
#
|
42
|
+
# Global options
|
43
|
+
# --------------
|
44
|
+
# set :ssh_options, {
|
45
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
46
|
+
# forward_agent: false,
|
47
|
+
# auth_methods: %w(password)
|
48
|
+
# }
|
49
|
+
#
|
50
|
+
# The server-based syntax can be used to override options:
|
51
|
+
# ------------------------------------
|
52
|
+
# server 'example.com',
|
53
|
+
# user: 'user_name',
|
54
|
+
# roles: %w{web app},
|
55
|
+
# ssh_options: {
|
56
|
+
# user: 'user_name', # overrides user setting above
|
57
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
58
|
+
# forward_agent: false,
|
59
|
+
# auth_methods: %w(publickey password)
|
60
|
+
# # password: 'please use keys'
|
61
|
+
# }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
require 'dotenv'
|
9
|
+
require 'daemons'
|
10
|
+
require 'slnky/service/example'
|
11
|
+
Dotenv.load
|
12
|
+
|
13
|
+
# Become a daemon
|
14
|
+
Daemons.daemonize if ARGV[1] == 'run'
|
15
|
+
|
16
|
+
Slnky::Service::Example.new(ENV['SLNKY_URL']).start
|
data/slnky.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'slnky/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "slnky"
|
8
|
+
spec.version = Slnky::VERSION
|
9
|
+
spec.authors = ["Shawn Catanzarite"]
|
10
|
+
spec.email = ["me@shawncatz.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{core slnky lib}
|
13
|
+
spec.description = %q{core slnky lib}
|
14
|
+
spec.homepage = "https://github.com/shawncatz/slnky"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# # delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|scripts)/}) }
|
26
|
+
spec.bindir = "bin"
|
27
|
+
spec.executables = spec.files.grep(%r{^#{spec.bindir}/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
|
34
|
+
spec.add_dependency 'dotenv', '~> 2.1.0'
|
35
|
+
spec.add_dependency 'amqp', '~> 1.5.1'
|
36
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
37
|
+
spec.add_dependency 'activesupport', '~> 4.2.5.1'
|
38
|
+
spec.add_dependency 'tilt', '~> 2.0.2'
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slnky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shawn Catanzarite
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dotenv
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: amqp
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.5.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.5.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.19.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.19.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 4.2.5.1
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 4.2.5.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tilt
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.0.2
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.0.2
|
125
|
+
description: core slnky lib
|
126
|
+
email:
|
127
|
+
- me@shawncatz.com
|
128
|
+
executables:
|
129
|
+
- slnky
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CODE_OF_CONDUCT.md
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/slnky
|
142
|
+
- lib/capistrano/slnky.rb
|
143
|
+
- lib/capistrano/tasks/slnky.rake
|
144
|
+
- lib/slnky.rb
|
145
|
+
- lib/slnky/cli.rb
|
146
|
+
- lib/slnky/cli/generate.rb
|
147
|
+
- lib/slnky/ext/deep_struct.rb
|
148
|
+
- lib/slnky/generator.rb
|
149
|
+
- lib/slnky/generator/command.rb
|
150
|
+
- lib/slnky/generator/service.rb
|
151
|
+
- lib/slnky/message.rb
|
152
|
+
- lib/slnky/service.rb
|
153
|
+
- lib/slnky/template/service/.env.sample
|
154
|
+
- lib/slnky/template/service/.gitignore
|
155
|
+
- lib/slnky/template/service/.rspec
|
156
|
+
- lib/slnky/template/service/.travis.yml
|
157
|
+
- lib/slnky/template/service/CODE_OF_CONDUCT.md
|
158
|
+
- lib/slnky/template/service/Capfile
|
159
|
+
- lib/slnky/template/service/Gemfile
|
160
|
+
- lib/slnky/template/service/config/deploy.rb.erb
|
161
|
+
- lib/slnky/template/service/config/deploy/production.rb
|
162
|
+
- lib/slnky/template/service/config/deploy/staging.rb
|
163
|
+
- lib/slnky/template/service/lib/capistrano/tasks/NAME.rake.erb
|
164
|
+
- lib/slnky/template/service/lib/slnky/service/NAME.rb.erb
|
165
|
+
- lib/slnky/template/service/service.erb
|
166
|
+
- lib/slnky/template/service/spec/slnky/service/NAME_spec.rb.erb
|
167
|
+
- lib/slnky/template/service/spec/spec_helper.rb.erb
|
168
|
+
- lib/slnky/template/service/upstart/init.conf.erb
|
169
|
+
- lib/slnky/version.rb
|
170
|
+
- slnky.gemspec
|
171
|
+
homepage: https://github.com/shawncatz/slnky
|
172
|
+
licenses:
|
173
|
+
- MIT
|
174
|
+
metadata: {}
|
175
|
+
post_install_message:
|
176
|
+
rdoc_options: []
|
177
|
+
require_paths:
|
178
|
+
- lib
|
179
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
requirements: []
|
190
|
+
rubyforge_project:
|
191
|
+
rubygems_version: 2.4.7
|
192
|
+
signing_key:
|
193
|
+
specification_version: 4
|
194
|
+
summary: core slnky lib
|
195
|
+
test_files: []
|