summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-08-13 12:58:36 +0300
committerSteve Kemp <steve@steve.org.uk>2015-08-13 12:58:36 +0300
commita202827d441c3afe2ed81da32593ed2f7397228b (patch)
treeaae5d5d528d00cbc1d59bbae0c16f71a94b01c29 /lib
parent0fc32727474ed8f072a1692bb0e91178b2a6c663 (diff)
Abort cleanly if we cannot acquire our lockfile.
This avoids a backtrace, and shows a clean reason for failure.
Diffstat (limited to 'lib')
-rw-r--r--lib/byteback/util.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/byteback/util.rb b/lib/byteback/util.rb
index 99a5b23..9a993d6 100644
--- a/lib/byteback/util.rb
+++ b/lib/byteback/util.rb
@@ -35,8 +35,12 @@ module Byteback
end
# Own the pidfile ourselves
- File.open(@@lockfile, 'w') do |lockfile|
- lockfile.puts Process.pid
+ begin
+ File.open(@@lockfile, 'w') do |lockfile|
+ lockfile.puts Process.pid
+ end
+ rescue => _ex
+ fatal("Failed to open lockfile - are you running as root?")
end
end