process-daemon 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 576478e27475cd8801ce2ea13053480531c13ea4
4
- data.tar.gz: 8ec4d0c286a5d0630c357ec529b54611abf54204
3
+ metadata.gz: 5ece8e79345bfaabb606ac9b0b2be85dc176ff1d
4
+ data.tar.gz: f199756be6f1625ee83a19795a111f67e8672406
5
5
  SHA512:
6
- metadata.gz: ffba1f40b923721772b95a2544c1e1ef1a19a9a2547fe92f41109cfb9802c4b30759a07382b1619adf5e7ad4746c0af00958c62a642b9f8de8110d1378afec43
7
- data.tar.gz: 0eb84df60f7380f8ec498e28dcdd36ffc458e3392819e2ff91d2d2bdc0f35315e1f5175d772bbca9833fa3e4eb9d37803ebf71a1b100eb90db5baab9278439e4
6
+ metadata.gz: 718589f9efa869b8256c065f74b8e6b234722a8e6862060f0fa1faf4f6b46fd92d3952f702e160d4ad9d1a3f0778c75d19e8609bb98ba7685af180b90d44eae2
7
+ data.tar.gz: c5063b89bda0d750da4298b318d91cdd914cb6c225e06562a4ca6b3975f7fa5c507a6b81812ae2f4788119fc1c562075e5286caf6fb8ddd944e5944e756bca59
@@ -39,7 +39,7 @@ module Process
39
39
 
40
40
  # This function is called from the daemon executable. It processes ARGV and checks whether the user is asking for `start`, `stop`, `restart`, `status`.
41
41
  def daemonize(argv = ARGV)
42
- case argv.shift.to_sym
42
+ case (argv.shift || :default).to_sym
43
43
  when :start
44
44
  start
45
45
  status
@@ -55,7 +55,7 @@ module Process
55
55
  when :status
56
56
  status
57
57
  else
58
- @stderr.puts Rainbow("Invalid command. Please specify start, restart, stop or status.").red
58
+ @output.puts Rainbow("Invalid command. Please specify start, restart, stop or status.").red
59
59
  end
60
60
  end
61
61
 
@@ -22,7 +22,7 @@ require 'etc'
22
22
 
23
23
  module Process
24
24
  class Daemon
25
- module Priviledges
25
+ module Privileges
26
26
  # Set the user of the current process. Supply either a user ID
27
27
  # or a user name.
28
28
  def self.change_user(user)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Process
22
22
  class Daemon
23
- VERSION = "0.5.4"
23
+ VERSION = "0.5.5"
24
24
  end
25
25
  end
@@ -28,118 +28,114 @@ require 'webrick/https'
28
28
  require 'xmlrpc/server'
29
29
  require 'xmlrpc/client'
30
30
 
31
- module Process
32
- class Daemon
33
- module DaemonSpec
34
- # Very simple XMLRPC daemon
35
- class XMLRPCDaemon < Process::Daemon
36
- def working_directory
37
- File.expand_path("../tmp", __FILE__)
38
- end
39
-
40
- def startup
41
- puts "Starting server..."
42
-
43
- @rpc_server = WEBrick::HTTPServer.new(
44
- :Port => 31337,
45
- :BindAddress => "0.0.0.0"
46
- )
47
-
48
- @listener = XMLRPC::WEBrickServlet.new
49
-
50
- @listener.add_handler("add") do |amount|
51
- @count ||= 0
52
- @count += amount
53
- end
54
-
55
- @listener.add_handler("total") do
56
- @count
57
- end
58
-
59
- @rpc_server.mount("/RPC2", @listener)
60
-
61
- begin
62
- puts "Daemon starting..."
63
- @rpc_server.start
64
- puts "Daemon stopping..."
65
- rescue Interrupt
66
- puts "Daemon interrupted..."
67
- ensure
68
- puts "Daemon shutdown..."
69
- @rpc_server.shutdown
70
- end
71
- end
72
-
73
- def shutdown
74
- puts "Stopping the RPC server..."
75
- @rpc_server.stop
76
- end
77
- end
31
+ module Process::Daemon::DaemonSpec
32
+ # Very simple XMLRPC daemon
33
+ class XMLRPCDaemon < Process::Daemon
34
+ def working_directory
35
+ File.expand_path("../tmp", __FILE__)
36
+ end
37
+
38
+ def startup
39
+ puts "Starting server..."
78
40
 
79
- class SleepDaemon < Process::Daemon
80
- def working_directory
81
- File.expand_path("../tmp", __FILE__)
82
- end
41
+ @rpc_server = WEBrick::HTTPServer.new(
42
+ :Port => 31337,
43
+ :BindAddress => "0.0.0.0"
44
+ )
45
+
46
+ @listener = XMLRPC::WEBrickServlet.new
47
+
48
+ @listener.add_handler("add") do |amount|
49
+ @count ||= 0
50
+ @count += amount
51
+ end
83
52
 
84
- def startup
85
- sleep 1 while true
86
- end
53
+ @listener.add_handler("total") do
54
+ @count
87
55
  end
88
56
 
89
- describe Daemon do
90
- before do
91
- XMLRPCDaemon.start
92
- end
93
-
94
- after do
95
- XMLRPCDaemon.stop
96
- end
97
-
98
- it "should be running" do
99
- expect(XMLRPCDaemon.status).to be == :running
100
- end
101
-
102
- it "should respond to connections" do
103
- rpc = XMLRPC::Client.new_from_uri("http://localhost:31337")
104
- rpc.call("add", 10)
105
-
106
- total = rpc.call("total")
107
-
108
- expect(total).to be == 10
109
- end
110
-
111
- it "should be a unique instance" do
112
- expect(XMLRPCDaemon.instance).to_not be == SleepDaemon.instance
113
- end
114
-
115
- it "should produce useful output" do
116
- output = StringIO.new
117
-
118
- controller = Process::Daemon::Controller.new(XMLRPCDaemon.instance, :output => output)
119
-
120
- expect(controller.status).to be == :running
121
-
122
- expect(output.string).to match /Daemon status: running pid=\d+/
123
-
124
- output.rewind
125
- controller.stop
126
-
127
- expect(output.string).to match /Stopping/
128
-
129
- output.rewind
130
- controller.start
131
-
132
- expect(output.string).to match /Starting/
133
- end
134
-
135
- it "should have correct process title" do
136
- pid = XMLRPCDaemon.controller.pid
137
-
138
- title = `ps -p #{pid} -o command=`.strip
139
-
140
- expect(title).to match /XMLRPCDaemon/
141
- end
57
+ @rpc_server.mount("/RPC2", @listener)
58
+
59
+ begin
60
+ puts "Daemon starting..."
61
+ @rpc_server.start
62
+ puts "Daemon stopping..."
63
+ rescue Interrupt
64
+ puts "Daemon interrupted..."
65
+ ensure
66
+ puts "Daemon shutdown..."
67
+ @rpc_server.shutdown
142
68
  end
143
69
  end
70
+
71
+ def shutdown
72
+ puts "Stopping the RPC server..."
73
+ @rpc_server.stop
74
+ end
75
+ end
76
+
77
+ class SleepDaemon < Process::Daemon
78
+ def working_directory
79
+ File.expand_path("../tmp", __FILE__)
80
+ end
81
+
82
+ def startup
83
+ sleep 1 while true
84
+ end
85
+ end
86
+
87
+ describe Process::Daemon do
88
+ before do
89
+ XMLRPCDaemon.start
90
+ end
91
+
92
+ after do
93
+ XMLRPCDaemon.stop
94
+ end
95
+
96
+ it "should be running" do
97
+ expect(XMLRPCDaemon.status).to be == :running
98
+ end
99
+
100
+ it "should respond to connections" do
101
+ rpc = XMLRPC::Client.new_from_uri("http://localhost:31337")
102
+ rpc.call("add", 10)
103
+
104
+ total = rpc.call("total")
105
+
106
+ expect(total).to be == 10
107
+ end
108
+
109
+ it "should be a unique instance" do
110
+ expect(XMLRPCDaemon.instance).to_not be == SleepDaemon.instance
111
+ end
112
+
113
+ it "should produce useful output" do
114
+ output = StringIO.new
115
+
116
+ controller = Process::Daemon::Controller.new(XMLRPCDaemon.instance, :output => output)
117
+
118
+ expect(controller.status).to be == :running
119
+
120
+ expect(output.string).to match /Daemon status: running pid=\d+/
121
+
122
+ output.rewind
123
+ controller.stop
124
+
125
+ expect(output.string).to match /Stopping/
126
+
127
+ output.rewind
128
+ controller.start
129
+
130
+ expect(output.string).to match /Starting/
131
+ end
132
+
133
+ it "should have correct process title" do
134
+ pid = XMLRPCDaemon.controller.pid
135
+
136
+ title = `ps -p #{pid} -o command=`.strip
137
+
138
+ expect(title).to match /XMLRPCDaemon/
139
+ end
144
140
  end
145
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process-daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -81,7 +81,7 @@ files:
81
81
  - lib/process/daemon.rb
82
82
  - lib/process/daemon/controller.rb
83
83
  - lib/process/daemon/log_file.rb
84
- - lib/process/daemon/priviledges.rb
84
+ - lib/process/daemon/privileges.rb
85
85
  - lib/process/daemon/process_file.rb
86
86
  - lib/process/daemon/version.rb
87
87
  - process-daemon.gemspec