synapse-rails 0.0.2
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/lib/synapse/providers.rb +10 -0
- data/lib/synapse/rails/consul.rb +50 -0
- data/lib/synapse/rails/engine.rb +17 -0
- data/lib/synapse/rails/haproxy.rb +88 -0
- data/lib/synapse/rails/linker.rb +57 -0
- data/lib/synapse/rails/provider_proxy.rb +35 -0
- data/lib/synapse/rails/providers/base.rb +77 -0
- data/lib/synapse/rails/providers.rb +36 -0
- data/lib/synapse/rails/version.rb +5 -0
- data/lib/synapse/rails.rb +18 -0
- data/lib/synapse/tenancy.rb +10 -0
- data/lib/tasks/synapse_rails_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/synapse_rails_test.rb +7 -0
- data/test/test_helper.rb +20 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edf89de23d27e1722be376da562d92b87d937206
|
4
|
+
data.tar.gz: 1f95af34df7ae8d58256ce70feac6b56f7311155
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1614b698335f5d36fd59c19480c3aaea3075d7ec7c9d3adf71956322f5838a89478d8c5f09f6bf87d586ad06bbb5b38b6876de27e99461f5d8dca622db92436e
|
7
|
+
data.tar.gz: 03d95db19a6623e8426b48db1adc7ebba7e00a9d9e038333962119de20fa5ab903e788a2ec8c46ff501c0f1e951abeef2ea2805c9bf8f548b9592f0cce8c4e9f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Mathias Kaufmann
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'SynapseRails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Synapse
|
2
|
+
module Providers
|
3
|
+
def use service, test=nil, params={}
|
4
|
+
provider = ::Synapse::Rails::Providers.for(service,params) unless test
|
5
|
+
provider = ::Synapse::Rails::Providers.use(service,params.merge(if:test)) if test
|
6
|
+
return unless provider
|
7
|
+
::Synapse::Rails.add_service_provider provider
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'resolv'
|
2
|
+
|
3
|
+
module Synapse
|
4
|
+
module Rails
|
5
|
+
class Consul
|
6
|
+
class << self
|
7
|
+
attr_accessor :datacenter
|
8
|
+
def hostnames params={}
|
9
|
+
return unless params[:for]
|
10
|
+
[
|
11
|
+
("#{params[:for]}.service.#{datacenter}.consul" if datacenter),
|
12
|
+
"#{params[:for]}.service.consul."
|
13
|
+
].compact
|
14
|
+
end
|
15
|
+
def discover service
|
16
|
+
resolv hostnames for:service
|
17
|
+
end
|
18
|
+
def resolv hostnames
|
19
|
+
@resolvers ||= Set.new
|
20
|
+
hostnames.collect do |hostname|
|
21
|
+
if @resolvers.empty?
|
22
|
+
resolv_and_check_resolver_with hostname
|
23
|
+
else
|
24
|
+
use_resolvers hostname
|
25
|
+
end
|
26
|
+
end.flatten
|
27
|
+
end
|
28
|
+
def use_resolvers hostname
|
29
|
+
@resolvers.collect do |resolver|
|
30
|
+
resolver.getaddresses hostname
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def resolv_and_check_resolver_with hostname
|
34
|
+
[host_resolver,local_consul_resolver].each do |resolver|
|
35
|
+
addresses = resolver.getaddresses hostname
|
36
|
+
next if addresses.empty?
|
37
|
+
@resolvers << resolver
|
38
|
+
return addresses
|
39
|
+
end
|
40
|
+
end
|
41
|
+
def host_resolver
|
42
|
+
@host_resolver ||= Resolv::DNS.new
|
43
|
+
end
|
44
|
+
def local_consul_resolver
|
45
|
+
@local_consul_resolver ||= Resolv::DNS.new(nameserver_port:[['127.0.0.1',8600]])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Synapse
|
2
|
+
module Rails
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace ::Synapse::Rails
|
5
|
+
config.before_configuration do |app|
|
6
|
+
::Synapse::Tenancy.application = app.class.parent_name.underscore
|
7
|
+
::Synapse::Rails.use :postgresql, :PG
|
8
|
+
::Synapse::Rails.use :mysql, :Mysql2
|
9
|
+
::Synapse::Rails.use :memcached, :Dalli
|
10
|
+
::Synapse::Rails.use :redis, :Redis
|
11
|
+
::Synapse::Rails.use :smtp, :ActionMailer
|
12
|
+
::Synapse::Rails.use :zookeeper, :ZK, check: false
|
13
|
+
::Synapse::Rails.start
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Synapse
|
4
|
+
module Rails
|
5
|
+
module Haproxy
|
6
|
+
attr_writer :reload_command, :config_file_path, :socket_file_path, :pid_file_path, :do_writes, :do_reloads, :do_socket, :global, :defaults, :extra_sections
|
7
|
+
def reload_command
|
8
|
+
@reload_command || "haproxy -f '#{config_file_path}' -p '#{pid_file_path}' -st $(cat '#{pid_file_path}' 2>/dev/null|| true)"
|
9
|
+
end
|
10
|
+
def instance_name
|
11
|
+
"synapse_#{instance}"
|
12
|
+
end
|
13
|
+
def workdir
|
14
|
+
@workdir ||= ::Rails.root unless ::Rails.root.to_s.size > 42
|
15
|
+
@workdir ||= Pathname.new "/tmp"
|
16
|
+
end
|
17
|
+
def config_file_path
|
18
|
+
@config_file_path ||= workdir.join("tmp","#{instance_name}.cfg").to_s
|
19
|
+
FileUtils.mkdir_p File.dirname @config_file_path
|
20
|
+
@config_file_path
|
21
|
+
end
|
22
|
+
def socket_file_path
|
23
|
+
@socket_file_path ||= workdir.join("tmp","sockets","#{instance_name}.sock").to_s
|
24
|
+
FileUtils.mkdir_p File.dirname @socket_file_path
|
25
|
+
@socket_file_path
|
26
|
+
end
|
27
|
+
def pid_file_path
|
28
|
+
@pid_file_path ||= workdir.join("tmp","pids","#{instance_name}.pid").to_s
|
29
|
+
FileUtils.mkdir_p File.dirname @pid_file_path
|
30
|
+
@pid_file_path
|
31
|
+
end
|
32
|
+
def do_writes
|
33
|
+
@do_writes || true
|
34
|
+
end
|
35
|
+
def do_reloads
|
36
|
+
@do_reloads || true
|
37
|
+
end
|
38
|
+
def do_socket
|
39
|
+
@do_socket || true
|
40
|
+
end
|
41
|
+
def global
|
42
|
+
@global || ["daemon","maxconn 4096","stats socket #{socket_file_path} mode 666 level admin"]
|
43
|
+
end
|
44
|
+
def defaults
|
45
|
+
@defaults || ["log global","option dontlognull","maxconn 1024","retries 3","timeout connect 5s","timeout client 60s","timeout server 60s","option redispatch","balance roundrobin"]
|
46
|
+
end
|
47
|
+
def extra_sections
|
48
|
+
@extra_sections || {
|
49
|
+
"listen stats 127.0.0.1:#{::Synapse::Rails::Haproxy.port}" => [
|
50
|
+
"mode http",
|
51
|
+
"stats enable",
|
52
|
+
"stats uri /",
|
53
|
+
"stats refresh 5s"
|
54
|
+
]
|
55
|
+
}
|
56
|
+
end
|
57
|
+
def instance
|
58
|
+
@instance ||= SecureRandom.hex(3)
|
59
|
+
end
|
60
|
+
def haproxy
|
61
|
+
%i{reload_command config_file_path socket_file_path do_writes do_reloads do_socket global defaults extra_sections}.collect do |section|
|
62
|
+
[section,self.send(section)]
|
63
|
+
end.to_h.with_indifferent_access
|
64
|
+
end
|
65
|
+
class << self
|
66
|
+
def port
|
67
|
+
@highport_start||=2<<9
|
68
|
+
@highport_range||=((2<<15)-@highport_start-1)
|
69
|
+
(2<<15).times do
|
70
|
+
port = @highport_start + SecureRandom.random_number(@highport_range)
|
71
|
+
return port if usable port
|
72
|
+
end
|
73
|
+
end
|
74
|
+
private
|
75
|
+
def usable port
|
76
|
+
begin
|
77
|
+
s = Socket.new(Socket::AF_INET,Socket::SOCK_STREAM,0)
|
78
|
+
s.connect(Socket.pack_sockaddr_in( port, '127.0.0.1' ))
|
79
|
+
s.close
|
80
|
+
false
|
81
|
+
rescue Errno::ECONNREFUSED
|
82
|
+
true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Synapse
|
2
|
+
module Rails
|
3
|
+
module Linker
|
4
|
+
attr_accessor :synapse_instance
|
5
|
+
def add_service_provider provider
|
6
|
+
@services ||= []
|
7
|
+
@services << provider
|
8
|
+
self.define_singleton_method(provider.service_name.to_sym){provider}
|
9
|
+
unless self.respond_to? (provider.service.to_sym)
|
10
|
+
self.define_singleton_method(provider.service.to_sym){provider}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
def services
|
14
|
+
@services.collect do |service|
|
15
|
+
[service.service_name,service.synapse]
|
16
|
+
end.to_h.with_indifferent_access
|
17
|
+
end
|
18
|
+
def synapse
|
19
|
+
@synapse ||= {
|
20
|
+
services:services,
|
21
|
+
haproxy:haproxy
|
22
|
+
}.with_indifferent_access unless @started
|
23
|
+
@synapse
|
24
|
+
end
|
25
|
+
def prepare
|
26
|
+
@synapse_instance ||= ::Synapse::Synapse.new synapse
|
27
|
+
end
|
28
|
+
def wait
|
29
|
+
loop do
|
30
|
+
break unless @synapse_instance.instance_variable_get("@haproxy").instance_variable_get("@restart_required")
|
31
|
+
sleep 0.01
|
32
|
+
end
|
33
|
+
end
|
34
|
+
def started?
|
35
|
+
@started || false
|
36
|
+
end
|
37
|
+
def start
|
38
|
+
prepare
|
39
|
+
@started = true
|
40
|
+
@marshal = Thread.new do
|
41
|
+
synapse_instance.run
|
42
|
+
end
|
43
|
+
at_exit do
|
44
|
+
puts "Stopping HAProxy"
|
45
|
+
`cat #{pid_file_path} | xargs kill -9` if File.exists? pid_file_path
|
46
|
+
puts "Remove PID-File"
|
47
|
+
File.unlink pid_file_path if File.exists? pid_file_path
|
48
|
+
puts "Remove Socket-File"
|
49
|
+
File.unlink socket_file_path if File.exists? socket_file_path
|
50
|
+
puts "Remove Config-File"
|
51
|
+
File.unlink config_file_path if File.exists? config_file_path
|
52
|
+
end
|
53
|
+
wait
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Synapse
|
2
|
+
module Rails
|
3
|
+
class ProviderProxy
|
4
|
+
attr_accessor :mode, :uri, :check, :inter, :rise, :fall
|
5
|
+
def initialize params={}
|
6
|
+
@mode = ( params[:mode] || "tcp" )
|
7
|
+
@check = params[:check] == nil ? true : params[:check]
|
8
|
+
@uri = params[:uri]
|
9
|
+
@inter = ( params[:inter] || "2s" )
|
10
|
+
@rise = ( params[:rise] || 2 )
|
11
|
+
@fall = ( params[:fall] || 3 )
|
12
|
+
end
|
13
|
+
def haproxy
|
14
|
+
{
|
15
|
+
port: port,
|
16
|
+
listen: listen,
|
17
|
+
server_options: server_options
|
18
|
+
}.with_indifferent_access
|
19
|
+
end
|
20
|
+
def server_options
|
21
|
+
return "check inter #{inter} rise #{rise} fall #{fall}" if check
|
22
|
+
""
|
23
|
+
end
|
24
|
+
def listen
|
25
|
+
@listen = []
|
26
|
+
@listen << "mode #{mode}"
|
27
|
+
@listen << "option httpchk #{uri}" if uri
|
28
|
+
@listen
|
29
|
+
end
|
30
|
+
def port
|
31
|
+
::Synapse::Rails::Haproxy.port
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Synapse
|
2
|
+
module Rails
|
3
|
+
module Providers
|
4
|
+
class Base
|
5
|
+
class << self
|
6
|
+
attr_accessor :service, :tester
|
7
|
+
attr_writer :base_path
|
8
|
+
def base_path
|
9
|
+
@base_path ||= "/nerve"
|
10
|
+
end
|
11
|
+
def hosts
|
12
|
+
@hosts ||= ::Synapse::Rails::Consul.discover(:zookeeper).collect do |address|
|
13
|
+
"#{address}:#{ZK.default_port}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
attr_accessor :function, :check
|
18
|
+
def initialize params={}
|
19
|
+
@function = "common"
|
20
|
+
@default_servers = []
|
21
|
+
config params
|
22
|
+
end
|
23
|
+
def path
|
24
|
+
[base_path,::Synapse::Tenancy.customer,service,function,"services"].join("/")
|
25
|
+
end
|
26
|
+
def hosts
|
27
|
+
@hosts ||= self.class.hosts
|
28
|
+
end
|
29
|
+
def discovery
|
30
|
+
%i{method path hosts}.collect do |element|
|
31
|
+
[element,self.send(element)]
|
32
|
+
end.to_h.with_indifferent_access
|
33
|
+
end
|
34
|
+
def haproxy
|
35
|
+
unless ::Synapse::Rails.started?
|
36
|
+
@haproxy = ::Synapse::Rails::ProviderProxy.new(check:@check).haproxy
|
37
|
+
end
|
38
|
+
@haproxy
|
39
|
+
end
|
40
|
+
def default_servers
|
41
|
+
@default_servers
|
42
|
+
end
|
43
|
+
def synapse
|
44
|
+
{
|
45
|
+
default_servers:default_servers,
|
46
|
+
discovery: discovery,
|
47
|
+
haproxy: haproxy,
|
48
|
+
}.with_indifferent_access
|
49
|
+
end
|
50
|
+
def config params={}
|
51
|
+
params.each do |k,v|
|
52
|
+
self.send(:"#{k}=",v) rescue nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
def service_name
|
56
|
+
[service,function].join("_")
|
57
|
+
end
|
58
|
+
def service
|
59
|
+
self.class.service
|
60
|
+
end
|
61
|
+
def host
|
62
|
+
"127.0.0.1"
|
63
|
+
end
|
64
|
+
def port
|
65
|
+
@haproxy[:port]
|
66
|
+
end
|
67
|
+
protected
|
68
|
+
def method
|
69
|
+
"zookeeper"
|
70
|
+
end
|
71
|
+
def base_path
|
72
|
+
self.class.base_path
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "synapse/rails/providers/base"
|
2
|
+
Dir.glob(File.join(File.expand_path("../providers",__FILE__),"*.rb")).each{|f|require_relative "providers/#{File.basename(f)}"}
|
3
|
+
|
4
|
+
module Synapse
|
5
|
+
module Rails
|
6
|
+
module Providers
|
7
|
+
class << self
|
8
|
+
def provider service, function='common'
|
9
|
+
@services
|
10
|
+
end
|
11
|
+
def for service, params={}
|
12
|
+
klass_name = "::Synapse::Rails::Providers::#{service.to_s.camelize}"
|
13
|
+
params = params.with_indifferent_access.except(:if)
|
14
|
+
Object.const_get(klass_name).new params
|
15
|
+
end
|
16
|
+
def use service, params={}
|
17
|
+
klass_name = "::Synapse::Rails::Providers::#{service.to_s.camelize}"
|
18
|
+
return self.send(:for,service,params) if Object.const_defined?(klass_name)
|
19
|
+
tester = params[:if] if params[:if].is_a? Proc
|
20
|
+
tester = Proc.new { Object.const_defined? params[:if] } if [Symbol, Class].include? params[:if].class
|
21
|
+
tester = Proc.new { true } if params[:if] == nil
|
22
|
+
return unless tester.call
|
23
|
+
build = true unless Object.const_defined? klass_name
|
24
|
+
build = true unless Object.const_defined?(klass_name).respond_to? :synapse
|
25
|
+
if build
|
26
|
+
klass = Class.new(Base)
|
27
|
+
klass.service = service
|
28
|
+
klass.tester = tester
|
29
|
+
self.const_set(klass_name.split('::').last,klass)
|
30
|
+
end
|
31
|
+
self.send(:for,service,params)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "synapse"
|
2
|
+
require "synapse/tenancy"
|
3
|
+
require "synapse/providers"
|
4
|
+
require "synapse/rails/consul"
|
5
|
+
require "synapse/rails/haproxy"
|
6
|
+
require "synapse/rails/provider_proxy"
|
7
|
+
require "synapse/rails/providers"
|
8
|
+
require "synapse/rails/linker"
|
9
|
+
|
10
|
+
module Synapse
|
11
|
+
module Rails
|
12
|
+
extend ::Synapse::Providers
|
13
|
+
extend ::Synapse::Rails::Haproxy
|
14
|
+
extend ::Synapse::Rails::Linker
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require "synapse/rails/engine"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "synapse/rails"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
|
22
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
+
config.active_record.raise_in_transactional_callbacks = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|