pid_lock 0.0.2 → 0.1.0

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: 0607895435d05927e618469540782eb8f0052adf
4
- data.tar.gz: 7c787ebf803fb0e20d7952e3c992f167956b7515
3
+ metadata.gz: fc28faa9e1aef44eb8a7abbce40928ce258f8bca
4
+ data.tar.gz: 39b5a5c7e50ebae667f6f794d689b166ba0ee402
5
5
  SHA512:
6
- metadata.gz: 126875be18d89ec08298ce70ad31857607b6c17e8174c589fc1048df1f8a60794e95b9bb298f5cf10f60d7a2760cb52a1a2a409ddc5df8db5fcf4d58bbb6371a
7
- data.tar.gz: deffd5d287509bdda51f673dff29656fe79ac0cfe38042bae90bad649611822bbfee39ada8e84b417de3f808fda06f71025b980b4856f250c8c73cfa3d9549c7
6
+ metadata.gz: 56a9cf07f838575d5f1e701f7a01ff6e44eb2492198b8a244fe4f315c7385c2adff6e563e3812a474d33847676204ce0defebeaed3a7187ecc27ff2825a4ca5a
7
+ data.tar.gz: 1fa4734eec304ff54f7ce77c374b500d96bc51cd8bc346eeb70a7850b339d6acdb1acdc5d2a218e1442fd57f0270dcea8447dfc3621fc1c619f044df68b97b97
data/lib/pid_lock.rb CHANGED
@@ -29,6 +29,15 @@ module PidLock
29
29
  end
30
30
  end
31
31
 
32
+ def stop(pid_name)
33
+ return unless File.exists?(File.join(pid_path, "#{pid_name}.pid"))
34
+ pid = File.read(File.join(pid_path, "#{pid_name}.pid"))
35
+ unless pid.to_s.empty?
36
+ Process.kill("QUIT", pid.to_i) rescue nil
37
+ end
38
+ unlock(pid_name)
39
+ end
40
+
32
41
  def pid(pid_name)
33
42
  File.read(File.join(pid_path, "#{pid_name}.pid")).to_i
34
43
  end
@@ -1,3 +1,3 @@
1
1
  module PidLock
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/pid_lock.gemspec CHANGED
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake", "~> 10.4"
23
+ spec.add_development_dependency "test-unit", "~> 2.5"
23
24
  end
@@ -1,4 +1,5 @@
1
1
  require 'test/unit'
2
+ require "pry"
2
3
 
3
4
  class TestPidLock < Test::Unit::TestCase
4
5
  def test_lock
@@ -15,4 +16,10 @@ class TestPidLock < Test::Unit::TestCase
15
16
  assert_equal false, PidLock.locked?('test')
16
17
  assert_equal false, File.exist?(File.join(PidLock.pid_path, "test.pid"))
17
18
  end
19
+
20
+ def test_stop
21
+ PidLock.lock('test')
22
+ PidLock.stop("test")
23
+ assert_equal false, PidLock.locked?('test')
24
+ end
18
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pid_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxiangyang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.5'
41
55
  description: ruby pid lock file
42
56
  email:
43
57
  - 54049924@qq.com
@@ -74,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
88
  version: '0'
75
89
  requirements: []
76
90
  rubyforge_project:
77
- rubygems_version: 2.2.2
91
+ rubygems_version: 2.4.8
78
92
  signing_key:
79
93
  specification_version: 4
80
94
  summary: ruby pid lock file