frontkick 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -1
- data/README.md +4 -0
- data/lib/frontkick/command.rb +11 -6
- data/lib/frontkick/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cb9b445262c3f7b278593b0bbb6bf54a14664e6
|
4
|
+
data.tar.gz: 6f557263aa916e8b293334da3e594931b552b721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f28fa5899334a518182cbce05bf4628001bc97c0cbe5e0997ecbbd2ccee374d5f4822a74ad22bce5fb09cd2e4e333bbe41181f118a24444dd3b3d5d68968228b
|
7
|
+
data.tar.gz: 4284c8e05039f6b3e478b3dc75959b715546a52efc82c9c5fbab27c03fc691f13a5b640e29bff07155d8f28ffa4cf7ec6970e9d169be83b20b7aec2416be776e
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,10 @@ Prohibit another process to run a command concurrently
|
|
39
39
|
|
40
40
|
Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
|
41
41
|
|
42
|
+
If you prefer to be blocked:
|
43
|
+
|
44
|
+
Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock", :exclusive_blocking => true)
|
45
|
+
|
42
46
|
## Contributing
|
43
47
|
|
44
48
|
1. Fork it
|
data/lib/frontkick/command.rb
CHANGED
@@ -8,7 +8,7 @@ module Frontkick
|
|
8
8
|
stdin, out, err, wait_thr, pid = nil
|
9
9
|
|
10
10
|
cmd_array = cmd.kind_of?(Array) ? cmd : [cmd]
|
11
|
-
lock_fd = file_lock(opts[:exclusive]) if opts[:exclusive]
|
11
|
+
lock_fd = file_lock(opts[:exclusive], opts[:exclusive_blocking]) if opts[:exclusive]
|
12
12
|
begin
|
13
13
|
timeout(opts[:timeout]) do # nil is for no timeout
|
14
14
|
duration = Benchmark.realtime do
|
@@ -50,14 +50,19 @@ module Frontkick
|
|
50
50
|
# Use file lock to perfome exclusive operation
|
51
51
|
#
|
52
52
|
# @param lock_file file path used to lock
|
53
|
+
# @param blocking blocking or non-blocking. default is nil (false)
|
53
54
|
# @return file descriptor
|
54
55
|
# @raise Fontkick::Locked if locked
|
55
|
-
def self.file_lock(lock_file)
|
56
|
+
def self.file_lock(lock_file, blocking = nil)
|
56
57
|
lock_fd = File.open(lock_file, File::RDWR|File::CREAT, 0644)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
if blocking
|
59
|
+
lock_fd.flock(File::LOCK_EX)
|
60
|
+
else
|
61
|
+
success = lock_fd.flock(File::LOCK_EX|File::LOCK_NB)
|
62
|
+
unless success
|
63
|
+
lock_fd.flock(File::LOCK_UN)
|
64
|
+
raise Frontkick::Locked
|
65
|
+
end
|
61
66
|
end
|
62
67
|
lock_fd
|
63
68
|
end
|
data/lib/frontkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.2.
|
96
|
+
rubygems_version: 2.2.0
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Execute a command simply!
|