daemontools 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9dfea32b1c19fb71a22c1e6fcd414522b7470cec233ddd85e54ee00c5e4eb82e
4
+ data.tar.gz: 5f2bd483ce8e98235039bd4c084d84a6b6cf0f2612f997be167a7b8e705f096a
5
+ SHA512:
6
+ metadata.gz: d2e573d9827f32d2ed84f93d4423526f416767ea8117aca68e544b931a9f211e138efa38bcd0d87e221ba98d7b9d6252f22131a8ff55f46bc7bf8981757366e8
7
+ data.tar.gz: 419eee00aef1789ea1ca2705548b0f0f385d5dd96e64165f83cdfee03202821449ea62e61ab6731ca5b7b07db38cdaefd6f5f38e0c492e8c1792ccbc09376beb
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rake'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Run tests'
7
+ RSpec::Core::RakeTask.new(:test) do |t|
8
+ t.rspec_opts = '--format documentation'
9
+ end
10
+
11
+ task :test
@@ -7,5 +7,16 @@ environment = ARGV[0] || "production"
7
7
  roles = ARGV[1] || ""
8
8
  puts "Building svc services for roles #{roles} .."
9
9
 
10
- builder = Daemontools::Builder.new("#{Dir.pwd}/config/services.rb")
11
- builder.gen(roles, environment)
10
+ old_path = ARGV[2] || ''
11
+ new_path = ARGV[3] || ''
12
+
13
+ if old_path.empty? || new_path.empty?
14
+ builder = Daemontools::Builder.new("#{Dir.pwd}/config/services.rb")
15
+ builder.gen(roles, environment)
16
+ else
17
+ previous_builder = Daemontools::Builder.new("#{old_path}/config/services.rb")
18
+ current_builder = Daemontools::Builder.new("#{new_path}/config/services.rb")
19
+ remover = Daemontools::Remover.new(roles, previous_builder, current_builder)
20
+ remover.remove_unused_services
21
+ current_builder.gen(roles, environment)
22
+ end
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_development_dependency "bundler"
21
21
  gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
22
23
  end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ run_command :command1, "cd /home/user/dir && command1 :task"
3
+ run_command :command2, "cd /home/user/dir && command2 :task"
4
+ run_command :command3, "cd /home/user/dir && command3 :task"
5
+ change_user_command 'setsid sudo -u'
6
+
7
+ service :service1, :roles => [:role_without_changes] do
8
+ command1 "service1.sh"
9
+ end
10
+
11
+ service :service_non_modified, :roles => [:role_with_modifies] do
12
+ command2 "service_non_modified.sh"
13
+ end
14
+
15
+ service :service2, :roles => [:role_with_deleted] do
16
+ command3 "bin/service3"
17
+ end
18
+
19
+ service :service3, :roles => [:role_without_changes] do
20
+ command3 "service3 -flag"
21
+ end
22
+
23
+ service :service_modified, :roles => [:role_with_modifies] do
24
+ command2 "task/SERVICE_MODIFIED.sh arg1"
25
+ end
26
+
27
+ service :service_new_1, :roles => [:role_with_modifies] do
28
+ command1 "service_new_1 arg1"
29
+ end
30
+
31
+ service :service_new_2, :roles => [:new_role] do
32
+ command1 "service_new_2 arg1"
33
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ run_command :command1, "cd /home/user/dir && command1 :task"
3
+ run_command :command2, "cd /home/user/dir && command2 :task"
4
+ run_command :command3, "cd /home/user/dir && command3 :task"
5
+ change_user_command 'setsid sudo -u'
6
+
7
+ service :service1, :roles => [:role_without_changes] do
8
+ command1 "service1.sh"
9
+ end
10
+
11
+ service :service_non_modified, :roles => [:role_with_modifies] do
12
+ command2 "service_non_modified.sh"
13
+ end
14
+
15
+ service :service2, :roles => [:role_with_deleted] do
16
+ command3 "bin/service3"
17
+ end
18
+
19
+ service :deleted_service_1, :roles => [:role_with_deleted] do
20
+ command1 "script/deleted_service_1 argument1 argument2"
21
+ end
22
+
23
+ service :service3, :roles => [:role_without_changes] do
24
+ command3 "service3 -flag"
25
+ end
26
+
27
+ service :service_modified, :roles => [:role_with_modifies] do
28
+ command2 "task/service_modified.sh arg1 arg2"
29
+ end
30
+
31
+ service :deleted_service_2, :roles => [:role_with_modifies] do
32
+ command2 "task/deleted_service_2.sh arg1 arg2"
33
+ end
34
+
35
+ service :deleted_service_3, :roles => [:role_deleted] do
36
+ command3 "script/deleted_service_3 argument1"
37
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ run_command :command1, "cd /home/user/dir && command1 :task"
3
+ run_command :command2, "cd /home/user/dir && command2 :task"
4
+ run_command :command3, "cd /home/user/dir && command3 :task"
5
+ change_user_command 'setsid sudo -u'
6
+ delete_command ''
7
+
8
+ service :service1, :roles => [:role1] do
9
+ command1 "service1.sh"
10
+ end
11
+
12
+ service :service2, :roles => [:role1] do
13
+ command2 "service2.sh"
14
+ end
15
+
16
+ service :service3, :roles => [:role1] do
17
+ command3 "bin/service3"
18
+ end
19
+
20
+ service :service4, :roles => [:role2] do
21
+ command1 "script/service4 argument1 argument2"
22
+ end
23
+
24
+ service :service5, :roles => [:role2] do
25
+ command3 "service5 -flag"
26
+ end
27
+
28
+ service :service6, :roles => [:role2] do
29
+ command2 "task/service6.sh arg1 arg2"
30
+ end
@@ -0,0 +1,13 @@
1
+ require 'daemontools'
2
+
3
+ module Daemontools
4
+ class BuilderStub < Builder
5
+ def start_service(_param1 = nil, _param2 = nil, _param3 = nil)
6
+ true
7
+ end
8
+
9
+ def delete_services(service_names, role)
10
+ find_services_by_name(service_names, role).map(&:first)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'daemontools'
2
+
3
+ module Daemontools
4
+ class RemoverStub < Remover
5
+ def remove_unused_services
6
+ return if @deleted_services.empty?
7
+
8
+ @deleted_services.map do |role, services|
9
+ @previous_builder.delete_services(services, role)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,6 @@
1
- require "daemontools/version"
2
- require "daemontools/service_builder"
1
+ require 'daemontools/version'
2
+ require 'daemontools/service_builder'
3
+ require 'daemontools/service_remover'
3
4
  require 'etc'
4
5
  require 'erb'
5
6
 
@@ -9,11 +10,11 @@ module Daemontools
9
10
  end
10
11
  @svc_root = '/etc/service'
11
12
  @log_root = '/var/log/svc'
12
-
13
+
13
14
  def self.exists?(name)
14
15
  check_service_exists(name, false)
15
16
  end
16
-
17
+
17
18
  def self.status(name)
18
19
  check_service_exists(name)
19
20
  r = `sudo svstat #{@path} 2>&1`
@@ -21,27 +22,27 @@ module Daemontools
21
22
  raise "Unknown status" unless r.match(/.*?:\s*(\S+).*\s(\d+) seconds.*/)
22
23
  [$1, $2.to_i]
23
24
  end
24
-
25
+
25
26
  def self.up?(name)
26
27
  status(name)[0] == "up"
27
28
  end
28
-
29
+
29
30
  def self.down?(name)
30
31
  status(name)[0] == "down"
31
32
  end
32
-
33
+
33
34
  def self.stop(name)
34
35
  run_svc(name, 'd')
35
36
  end
36
-
37
+
37
38
  def self.start(name)
38
39
  run_svc(name, 'u')
39
40
  end
40
-
41
+
41
42
  def self.restart(name)
42
43
  run_svc(name, 't')
43
44
  end
44
-
45
+
45
46
  def self.add_empty(name)
46
47
  path = "#{@svc_root}/#{name}"
47
48
  Dir.mkdir(path) unless Dir.exists?(path)
@@ -51,10 +52,11 @@ module Daemontools
51
52
  raise "Timeout wait for svc add service" if Time.now.to_f - now > 10
52
53
  sleep 0.1
53
54
  end
55
+ File.delete("#{path}/down")
54
56
  stop(name)
55
57
  true
56
58
  end
57
-
59
+
58
60
  def self.add(name, command, options = {})
59
61
  @name = name
60
62
  @command = command
@@ -62,7 +64,10 @@ module Daemontools
62
64
  @pre_command = options[:pre_command]
63
65
  @sleep = options[:sleep] || 3
64
66
  @path = "#{@svc_root}/#{name}"
65
-
67
+ @change_user_command = options[:change_user_command]
68
+ @ulimit = options[:ulimit]
69
+ @write_time = options[:write_time]
70
+
66
71
  if Dir.exists?(@path)
67
72
  stop(name)
68
73
  else
@@ -72,7 +77,7 @@ module Daemontools
72
77
  Dir.mkdir("#{@path}/log") unless Dir.exists?("#{@path}/log")
73
78
  File.open("#{@path}/log/run", 'w', 0755) {|f| f.write(run_template('log.erb'))}
74
79
  File.open("#{@path}/run", 'w', 0755) {|f| f.write(run_template('run.erb'))}
75
-
80
+
76
81
  unless options[:not_wait]
77
82
  wait_timeout = options[:wait_timeout] || 10
78
83
  now = Time.now.to_f
@@ -81,44 +86,45 @@ module Daemontools
81
86
  sleep 0.1
82
87
  end
83
88
  end
84
-
89
+
85
90
  true
86
91
  end
87
-
88
- def self.delete(name)
92
+
93
+ def self.delete(name, rm_cmd = nil)
89
94
  check_service_exists(name)
90
95
  stop(name)
91
- r = `sudo rm -rf #{@path} 2>&1`
96
+ cmd = rm_cmd.nil? ? "sudo rm -rf #{@path} 2>&1" : "#{rm_cmd} #{@path}"
97
+ r = `#{cmd}`
92
98
  raise r if $?.exitstatus != 0
93
99
  true
94
100
  end
95
-
101
+
96
102
  def self.run_status(name)
97
103
  check_service_exists(name)
98
104
  File.exists?("#{@path}/down") ? "down" : "up"
99
105
  end
100
-
106
+
101
107
  def self.run_status_up?(name)
102
108
  run_status(name) == "up"
103
109
  end
104
-
110
+
105
111
  def self.run_status_down?(name)
106
112
  run_status(name) == "down"
107
113
  end
108
-
114
+
109
115
  def self.make_run_status_up(name)
110
116
  File.delete("#{@path}/down")
111
117
  true
112
118
  end
113
-
119
+
114
120
  def self.make_run_status_down(name)
115
121
  check_service_exists(name)
116
122
  File.open("#{@path}/down", 'w') {|f| f.write('')}
117
123
  true
118
124
  end
119
-
125
+
120
126
  private
121
-
127
+
122
128
  def self.check_service_exists(name, raise_error = true)
123
129
  @path = "#{@svc_root}/#{name}"
124
130
  if raise_error
@@ -127,7 +133,7 @@ module Daemontools
127
133
  Dir.exists?(@path)
128
134
  end
129
135
  end
130
-
136
+
131
137
  def self.run_svc(name, command)
132
138
  check_service_exists(name)
133
139
  r = `sudo svc -#{command} #{@path} 2>&1`
@@ -135,9 +141,9 @@ module Daemontools
135
141
  raise r if ! r.empty?
136
142
  true
137
143
  end
138
-
144
+
139
145
  def self.run_template(template_name)
140
- @user = Etc.getlogin
146
+ @user = Etc.getpwuid(Process.uid).name
141
147
  template_path = File.expand_path(File.dirname(__FILE__))+'/../templates/'+template_name
142
148
  ERB.new(File.read(template_path)).result(binding())
143
149
  end
@@ -5,32 +5,32 @@ Capistrano::Configuration.instance(:must_exist).load do
5
5
  desc "Update daemontools services using services.rb"
6
6
  task :update do
7
7
  builder = Daemontools::Builder.new("#{Dir.pwd}/config/services.rb")
8
-
9
- servers = find_servers.inject({}) do |map, server|
8
+
9
+ servers = find_servers.inject({}) do |map, server|
10
10
  map[server] = role_names_for_host(server) & builder.all_roles
11
11
  map
12
12
  end.select {|server, roles| roles.size > 0}
13
-
13
+
14
14
  if servers.any?
15
15
  if task_call_frames[0].task.fully_qualified_name == 'deploy:rollback'
16
16
  path = fetch(:previous_release)
17
17
  puts "rollback 1"
18
18
  else
19
19
  path = fetch(:release_path)
20
-
20
+
21
21
  servers.each do |server, roles|
22
- command = "cd #{path} && bundle exec daemontools-gen #{fetch :rails_env, "production"} #{roles.join(',')}"
22
+ command = "cd #{path} && bundle exec daemontools-gen #{fetch :rails_env, "production"} #{roles.join(',')} #{current_path} #{release_path}"
23
23
  run command, :hosts => server
24
24
  end
25
25
  end
26
-
26
+
27
27
  on_rollback do
28
28
  puts "rollback 2"
29
29
  end
30
30
  end
31
31
  end
32
32
  end
33
-
33
+
34
34
  after "deploy:create_symlink", "daemontools:update"
35
35
  after "deploy:rollback", "daemontools:update"
36
36
  end
@@ -1,52 +1,84 @@
1
+ require 'fileutils'
2
+
1
3
  module Daemontools
2
4
  class Builder
3
- attr_accessor :environment, :all_roles, :services, :curr_service_name
4
-
5
+ attr_accessor :environment, :all_roles, :services, :curr_service_name, :change_user_command, :ulimit, :write_time, :delete_command
6
+
5
7
  def initialize(filename)
6
8
  @all_roles = []
7
9
  @services = {}
10
+ @change_user_command = 'setuidgid'
11
+ @ulimit = {}
12
+ @write_time = true
8
13
  eval(File.read(filename), binding())
9
14
  end
10
-
15
+
11
16
  def run_command(command_name, param)
12
17
  self.class.send(:define_method, command_name) do |task, options = {}|
13
18
  p = param.gsub(':task', task)
14
- options.each {|key, val| p.gsub!(":#{key}", val.to_s) }
15
- command(p, options)
19
+ options.each { |key, val| p.gsub!(":#{key}", val.to_s) }
20
+ p
16
21
  end
17
22
  end
18
-
19
- def command(param, options = {})
20
- Daemontools.stop(@curr_service_name) if Daemontools.exists?(@curr_service_name)
21
- @command = param.gsub(':environment', @environment)
22
- template_path = File.expand_path(File.dirname(__FILE__))+'/../../templates/rvm.erb'
23
- cmd = ERB.new(File.read(template_path)).result(binding())
24
- Daemontools.add(@curr_service_name, cmd)
25
- Daemontools.make_run_status_up(@curr_service_name)
26
- Daemontools.start(@curr_service_name)
27
- end
28
-
23
+
29
24
  def service(name, opts = {}, &block)
30
25
  if opts[:roles]
31
- opts[:roles].each do |role|
26
+ opts[:roles].each do |role|
32
27
  role = role.to_sym
33
28
  @all_roles << role unless @all_roles.member?(role)
34
29
  @services[role] = [] unless @services[role]
35
- @services[role] << [name, block]
30
+ @services[role] << [name, block.call]
36
31
  end
37
32
  else
38
33
  raise "service without roles"
39
34
  end
40
35
  end
41
-
36
+
42
37
  def gen(roles, env)
43
38
  @environment = env
44
- roles.split(',').each do |role|
39
+ roles.split(',').each do |role|
45
40
  (@services[role.to_sym] || []).each do |service|
46
41
  @curr_service_name = service[0].to_s
47
- service[1].call
42
+ start_service(service[1])
48
43
  end
49
44
  end
50
45
  end
46
+
47
+ def change_user_command(cmd)
48
+ @change_user_command = cmd
49
+ end
50
+
51
+ def ulimit(opt, val)
52
+ @ulimit[opt] = val
53
+ end
54
+
55
+ def write_time(val)
56
+ @write_time = val
57
+ end
58
+
59
+ def start_service(command, service = nil, env = nil)
60
+ @environment = env if env
61
+ @curr_service_name = service if service
62
+ Daemontools.stop(@curr_service_name) if Daemontools.exists?(@curr_service_name)
63
+ @command = command.gsub(':environment', @environment)
64
+ template_path = File.expand_path(File.dirname(__FILE__)) + '/../../templates/rvm.erb'
65
+ cmd = ERB.new(File.read(template_path)).result(binding())
66
+ Daemontools.add(@curr_service_name, cmd, { :change_user_command => @change_user_command, :ulimit => @ulimit, :write_time => @write_time })
67
+ Daemontools.make_run_status_up(@curr_service_name)
68
+ Daemontools.start(@curr_service_name)
69
+ end
70
+
71
+ def delete_command(cmd)
72
+ @delete_command = cmd.empty? ? nil : cmd
73
+ end
74
+
75
+ def delete_services(service_names, role)
76
+ services = find_services_by_name(service_names, role)
77
+ services.each { |service| Daemontools.delete(service[0], @delete_command) }
78
+ end
79
+
80
+ def find_services_by_name(service_names, role)
81
+ @services[role].select { |service| service_names.include?(service[0]) }
82
+ end
51
83
  end
52
- end
84
+ end
@@ -0,0 +1,36 @@
1
+ module Daemontools
2
+ class Remover
3
+ attr_accessor :previous_builder, :current_builder, :deleted_services
4
+
5
+ def initialize(roles, previous_builder, current_builder)
6
+ raise ArgumentError, "previous_builder couldn't be nil" if previous_builder.nil?
7
+ raise ArgumentError, "current_builder couldn't be nil" if current_builder.nil?
8
+
9
+ @roles = roles.split(',').map(&:to_sym)
10
+ @previous_builder = previous_builder
11
+ @current_builder = current_builder
12
+ find_services_changes(@previous_builder.services, @current_builder.services)
13
+ end
14
+
15
+ def remove_unused_services
16
+ return if @deleted_services.empty?
17
+
18
+ @deleted_services.each do |role, services|
19
+ puts "Delete services #{services} for role #{role}"
20
+ @previous_builder.delete_services(services, role)
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def find_services_changes(old_services, new_services)
27
+ @deleted_services = {}
28
+ @roles.each do |role|
29
+ old_role_services = (old_services[role] || []).map(&:first)
30
+ new_role_services = (new_services[role] || []).map(&:first)
31
+ services_for_del = old_role_services - new_role_services
32
+ @deleted_services[role] = services_for_del unless services_for_del.empty?
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module Daemontools
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'daemontools'
2
+
3
+ RSpec.describe Daemontools::Builder, '#initialize' do
4
+ context 'Check commands' do
5
+ builder = Daemontools::Builder.new("#{Dir.pwd}/fixtures/services.rb")
6
+ it 'Second element must be contain right string for COMMAND2 method' do
7
+ command = builder.services[:role1][1][1]
8
+ expect(command).to eq 'cd /home/user/dir && command2 service2.sh'
9
+ end
10
+ it 'Second element must be contain right string for COMMAND1 method' do
11
+ command = builder.services[:role1][0][1]
12
+ expect(command).to eq 'cd /home/user/dir && command1 service1.sh'
13
+ end
14
+ it 'Second element must be contain right string for COMMAND3 method' do
15
+ command = builder.services[:role1][2][1]
16
+ expect(command).to eq 'cd /home/user/dir && command3 bin/service3'
17
+ end
18
+ end
19
+ end
20
+
21
+ RSpec.describe Daemontools::Builder, '#delete_command' do
22
+ context 'Check delete_command method' do
23
+ builder = Daemontools::Builder.new("#{Dir.pwd}/fixtures/services.rb")
24
+ it 'Should return a nil after initialize' do
25
+ expect(builder.instance_variable_get(:@delete_command)).to eq nil
26
+ end
27
+ it 'Should return a nil after assignment an empty string' do
28
+ builder.delete_command ''
29
+ expect(builder.instance_variable_get(:@delete_command)).to eq nil
30
+ end
31
+ it 'Should return a the same string after assignment delete_command' do
32
+ delete_command = 'delete_command'
33
+ builder.delete_command delete_command
34
+ expect(builder.instance_variable_get(:@delete_command)).to eq delete_command
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ require 'daemontools'
2
+ require "#{Dir.pwd}/fixtures/stubs/service_builder_stub.rb"
3
+ require "#{Dir.pwd}/fixtures/stubs/service_remover_stub.rb"
4
+
5
+ RSpec.describe Daemontools::Remover, '#initialize' do
6
+ context 'Check initialization process' do
7
+ old_builder = Daemontools::BuilderStub.new("#{Dir.pwd}/fixtures/old_services.rb")
8
+ new_builder = Daemontools::BuilderStub.new("#{Dir.pwd}/fixtures/new_services.rb")
9
+
10
+ roles = old_builder.all_roles + new_builder.all_roles
11
+ roles += ['role_without_any_service']
12
+ roles.uniq!
13
+ roles = roles.join(',')
14
+
15
+ remover = Daemontools::RemoverStub.new(roles, old_builder, new_builder)
16
+ deleted = remover.deleted_services
17
+ deleted_roles = %i[role_with_deleted role_with_modifies role_deleted]
18
+
19
+ context 'Check roles where services were deleted' do
20
+ it 'Number of roles for deleted services must be equal to length of deleted roles' do
21
+ expect(deleted.keys.size).to eq deleted_roles.length
22
+ end
23
+
24
+ deleted.each_key do |role|
25
+ it "Should contain #{role}" do
26
+ expect(deleted_roles.include?(role)).to eq true
27
+ end
28
+ end
29
+ end
30
+
31
+ context 'Removing unused services' do
32
+ deleted_services_names = %i[deleted_service_1 deleted_service_2 deleted_service_3]
33
+ it 'Should remove services which was deleted' do
34
+ expect(remover.remove_unused_services.flatten.sort).to eq deleted_services_names.sort
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,100 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # This setting enables warnings. It's recommended, but in some cases may
70
+ # be too noisy due to issues in dependencies.
71
+ config.warnings = true
72
+
73
+ # Many RSpec users commonly either run the entire suite or an individual
74
+ # file, and it's useful to allow more verbose output when running an
75
+ # individual spec file.
76
+ if config.files_to_run.one?
77
+ # Use the documentation formatter for detailed output,
78
+ # unless a formatter has already been configured
79
+ # (e.g. via a command-line flag).
80
+ config.default_formatter = "doc"
81
+ end
82
+
83
+ # Print the 10 slowest examples and example groups at the
84
+ # end of the spec run, to help surface which specs are running
85
+ # particularly slow.
86
+ config.profile_examples = 10
87
+
88
+ # Run specs in random order to surface order dependencies. If you find an
89
+ # order dependency and want to debug it, you can fix the order by providing
90
+ # the seed, which is printed after each run.
91
+ # --seed 1234
92
+ config.order = :random
93
+
94
+ # Seed global randomization in this process using the `--seed` CLI option.
95
+ # Setting this allows you to use `--seed` to deterministically reproduce
96
+ # test failures related to randomization by passing the same `--seed` value
97
+ # as the one that triggered the failure.
98
+ Kernel.srand config.seed
99
+ =end
100
+ end
@@ -3,4 +3,4 @@
3
3
  LOGDIR=<%= @log_dir %>
4
4
  mkdir -p $LOGDIR
5
5
  <%= "chmod 0777 $LOGDIR" if @user %>
6
- exec <%= "setuidgid #{@user}" if @user %> multilog t s16000000 n25 $LOGDIR
6
+ exec <%= "setuidgid #{@user}" if @user %> multilog <%= "t " if @write_time %>s16000000 n25 $LOGDIR
@@ -1,5 +1,8 @@
1
1
  #!/bin/sh
2
+ <% @ulimit.each do |k,v| %>
3
+ ulimit -<%=k%> <%=v%>
4
+ <% end %>
2
5
  <%= "sleep #{@sleep}" if @sleep && @sleep.to_i > 0 %>
3
6
  exec 2>&1
4
7
  <%= @pre_command if @pre_command %>
5
- exec <%= "setuidgid #{@user}" if @user %> <%= @command %>
8
+ exec <%= "#{@change_user_command} #{@user}" if @user %> <%= @command %>
metadata CHANGED
@@ -1,46 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemontools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - sh
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: Distributed storage
@@ -51,48 +60,54 @@ executables:
51
60
  extensions: []
52
61
  extra_rdoc_files: []
53
62
  files:
54
- - .gitignore
63
+ - ".gitignore"
64
+ - ".rspec"
55
65
  - Gemfile
56
66
  - LICENSE.txt
57
67
  - README.md
58
68
  - Rakefile
59
69
  - bin/daemontools-gen
60
70
  - daemontools.gemspec
71
+ - fixtures/new_services.rb
72
+ - fixtures/old_services.rb
73
+ - fixtures/services.rb
74
+ - fixtures/stubs/service_builder_stub.rb
75
+ - fixtures/stubs/service_remover_stub.rb
61
76
  - lib/daemontools.rb
62
77
  - lib/daemontools/capistrano.rb
63
78
  - lib/daemontools/service_builder.rb
79
+ - lib/daemontools/service_remover.rb
64
80
  - lib/daemontools/version.rb
81
+ - spec/builder_spec.rb
82
+ - spec/service_delete_spec.rb
83
+ - spec/spec_helper.rb
65
84
  - templates/log.erb
66
85
  - templates/run.erb
67
86
  - templates/rvm.erb
68
87
  homepage: ''
69
88
  licenses: []
89
+ metadata: {}
70
90
  post_install_message:
71
91
  rdoc_options: []
72
92
  require_paths:
73
93
  - lib
74
94
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
95
  requirements:
77
- - - ! '>='
96
+ - - ">="
78
97
  - !ruby/object:Gem::Version
79
98
  version: '0'
80
- segments:
81
- - 0
82
- hash: -836446816853761681
83
99
  required_rubygems_version: !ruby/object:Gem::Requirement
84
- none: false
85
100
  requirements:
86
- - - ! '>='
101
+ - - ">="
87
102
  - !ruby/object:Gem::Version
88
103
  version: '0'
89
- segments:
90
- - 0
91
- hash: -836446816853761681
92
104
  requirements: []
93
105
  rubyforge_project:
94
- rubygems_version: 1.8.24
106
+ rubygems_version: 2.7.9
95
107
  signing_key:
96
- specification_version: 3
108
+ specification_version: 4
97
109
  summary: Distributed storage
98
- test_files: []
110
+ test_files:
111
+ - spec/builder_spec.rb
112
+ - spec/service_delete_spec.rb
113
+ - spec/spec_helper.rb