qnotifier 0.6.9 → 0.7.0
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.
- data/lib/command.rb +31 -10
- data/lib/qnotifier.rb +17 -1
- data/qnotifier.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
data/lib/command.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "qnotifier"
|
3
|
-
require "robustthread"
|
4
3
|
|
5
4
|
module Qnotifier
|
6
5
|
class Command
|
7
6
|
|
8
7
|
def self.run(argv)
|
9
8
|
unless Process.euid == 0
|
10
|
-
puts "QNotifier
|
11
|
-
exit
|
9
|
+
puts "QNotifier should be only started by root in order to set itself up"
|
12
10
|
end
|
13
11
|
|
14
12
|
if has_api_key?
|
@@ -43,6 +41,9 @@ module Qnotifier
|
|
43
41
|
$qnotifier_debug = true
|
44
42
|
qnotifier.run
|
45
43
|
|
44
|
+
elsif argv.first == 'setup-directories'
|
45
|
+
setup_directories
|
46
|
+
|
46
47
|
else
|
47
48
|
puts "usage: qnotifier start | stop | restart | zap | reset | register | debug"
|
48
49
|
puts "see http://qnotifier.com for more details"
|
@@ -148,6 +149,12 @@ module Qnotifier
|
|
148
149
|
|
149
150
|
def self.start
|
150
151
|
puts "Starting QNotifier..."
|
152
|
+
|
153
|
+
runlock_file = "/var/lib/qnotifier/.runlock"
|
154
|
+
if File.exists?(runlock_file)
|
155
|
+
`rm #{runlock_file}`
|
156
|
+
end
|
157
|
+
|
151
158
|
pid_file = "/var/lib/qnotifier/qnotifer.pid"
|
152
159
|
if running
|
153
160
|
puts "Daemon is already running, check pid #{pid_file}"
|
@@ -155,15 +162,29 @@ module Qnotifier
|
|
155
162
|
end
|
156
163
|
|
157
164
|
pid = fork do
|
158
|
-
|
159
|
-
|
160
|
-
|
165
|
+
$0 = 'qnotifierd'
|
166
|
+
Process.setsid
|
167
|
+
Process.uid = 65534 if Process.euid == 0
|
168
|
+
exit if fork
|
169
|
+
`echo #{Process.pid} > /var/lib/qnotifier/qnotifer.pid`
|
170
|
+
Dir.chdir "/var/lib/qnotifier"
|
171
|
+
File.umask 0000
|
172
|
+
STDIN.reopen "/dev/null"
|
173
|
+
STDOUT.reopen "/dev/null", "a"
|
174
|
+
STDERR.reopen STDOUT
|
175
|
+
trap("TERM") {daemon.stop; exit}
|
176
|
+
loop do
|
177
|
+
cpid = fork do
|
178
|
+
$0 = 'qnotifier-runner'
|
179
|
+
`touch /tmp/running-#{Process.pid}`
|
180
|
+
qnotifier = Qnotifier::MainProcess.new
|
181
|
+
qnotifier.run
|
182
|
+
end
|
183
|
+
Process.detach cpid
|
184
|
+
sleep 30
|
161
185
|
end
|
162
|
-
|
163
|
-
end
|
186
|
+
end
|
164
187
|
Process.detach pid
|
165
|
-
`echo #{pid} > /var/lib/qnotifier/qnotifer.pid`
|
166
|
-
puts "Running (#{pid})"
|
167
188
|
end
|
168
189
|
|
169
190
|
def self.stop
|
data/lib/qnotifier.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
2
4
|
require "yaml"
|
3
5
|
require "timeout"
|
4
6
|
require "logger"
|
@@ -43,6 +45,14 @@ module Qnotifier
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def run
|
48
|
+
runlock_file = "/var/lib/qnotifier/.runlock"
|
49
|
+
if File.exists?(runlock_file)
|
50
|
+
puts "Runlock exists at #{runlock_file} - process already running? Exiting."
|
51
|
+
exit
|
52
|
+
else
|
53
|
+
`echo #{Process.pid} > #{runlock_file}`
|
54
|
+
end
|
55
|
+
|
46
56
|
start_logging
|
47
57
|
load_config
|
48
58
|
|
@@ -83,6 +93,8 @@ module Qnotifier
|
|
83
93
|
|
84
94
|
# Done, clean up and save
|
85
95
|
Qnotifier::Storage.save
|
96
|
+
|
97
|
+
`rm #{runlock_file}`
|
86
98
|
end
|
87
99
|
|
88
100
|
def process_plugin_file(file)
|
@@ -179,4 +191,8 @@ module Qnotifier
|
|
179
191
|
end
|
180
192
|
end
|
181
193
|
end
|
182
|
-
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# The main part of the script
|
197
|
+
qnotifier = Qnotifier::MainProcess.new
|
198
|
+
qnotifier.run
|
data/qnotifier.gemspec
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|