gitdocs 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -36,6 +36,12 @@ You need to startup gitdocs:
36
36
  gitdocs start
37
37
  ```
38
38
 
39
+ If the start command doesn't seem to properly start the process, you can run with a debug flag:
40
+
41
+ ```
42
+ gitdocs start -D
43
+ ```
44
+
39
45
  You can also `stop` and `restart` gitdocs as needed. Run
40
46
 
41
47
  ```
data/lib/gitdocs.rb CHANGED
@@ -13,6 +13,7 @@ module Gitdocs
13
13
  def self.run(config_root = nil, debug=false)
14
14
  loop do
15
15
  @config = Configuration.new(config_root)
16
+ puts "Gitdocs v#{VERSION}" if debug
16
17
  puts "Using configuration root: '#{@config.config_root}'" if debug
17
18
  puts "Watch paths: #{@config.paths.join(", ")}" if debug
18
19
  @threads = @config.paths.map do |path|
data/lib/gitdocs/cli.rb CHANGED
@@ -11,7 +11,8 @@ module Gitdocs
11
11
  def start
12
12
  if !self.running? && !options[:debug]
13
13
  self.runner(:daemonize => true, :pid_path => self.pid_path).execute { Gitdocs.run }
14
- say "Started gitdocs", :green
14
+ until_true(5) { self.running? }
15
+ self.running? ? say("Started gitdocs", :green) : say("Failed to start gitdocs", :red)
15
16
  elsif !self.running? && options[:debug]
16
17
  say "Running in debug mode", :yellow
17
18
  Gitdocs.run(nil, true)
@@ -22,14 +23,18 @@ module Gitdocs
22
23
 
23
24
  desc "stop", "Stops the gitdocs process"
24
25
  def stop
25
- self.runner(:kill => true, :pid_path => self.pid_path).execute
26
- say "Stopped gitdocs", :red
26
+ if self.running?
27
+ self.runner(:kill => true, :pid_path => self.pid_path).execute
28
+ say "Stopped gitdocs", :red
29
+ else # not running
30
+ say "Gitdocs is not running", :red
31
+ end
27
32
  end
28
33
 
29
34
  desc "restart", "Restarts the gitdocs process"
30
35
  def restart
31
36
  self.stop
32
- sleep(1)
37
+ until_true(5) { self.running? }
33
38
  self.start
34
39
  end
35
40
 
@@ -108,6 +113,17 @@ module Gitdocs
108
113
  def pid_path
109
114
  "/tmp/gitdocs.pid"
110
115
  end
116
+
117
+ # Runs until the block condition is met or the retry_count is exceeded
118
+ # until_true(10) { ...return_condition... }
119
+ def until_true(retry_count, &block)
120
+ count = 0
121
+ while count < retry_count && block.call != true
122
+ count += 1
123
+ sleep(1)
124
+ end
125
+ count < retry_count
126
+ end
111
127
  end
112
128
 
113
129
  end
@@ -1,3 +1,3 @@
1
1
  module Gitdocs
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gitdocs
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Hull