brisk 0.1.0 → 0.1.1

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: 7fda12aee0efddd813bc88c4569ffe04cc38e9db
4
- data.tar.gz: fb8e0e72095b7af45f7b5265fc345edf5ada054e
3
+ metadata.gz: 4daa16b5c768b4813fe28e5242b265f6d989e929
4
+ data.tar.gz: 9340e9f58325c4dea48080d982a75dfa92c75862
5
5
  SHA512:
6
- metadata.gz: 0683d83026e1b2f5ee3396e3ac28c5c833eb05763e0b1222e3c811807c26ca9977df895c275ffd4e0b7b66022c8c60c8f069477c09c1abbbbe4eba5df172d8c6
7
- data.tar.gz: 3d41ccf08b7112a259d60cc9098dd3bf12c0ec5b5cf6a17cfae259adaa4edca71bc8e4c091f531e869f0337d181b4546c46fe74276cc1fd1a6a4824f0248d791
6
+ metadata.gz: 823564cfb0b65657dc8e54863307b9f81f61af90fa4bb27f9be4bddb6ec857f9f5365b0c7677cf53946472dc84ef47a5f48ec4b03fd205a52269b5b38c43d908
7
+ data.tar.gz: d4f7efb1f0894cc35fd11487ff9a760108d138d368bab952b13d53fb2b760a542639e2b85aefc88c45201517428159e27312043c95285af7e404058b5f2e4e98
@@ -15,4 +15,13 @@ class Pid
15
15
  def self.exists?(path)
16
16
  File.file?("#{path}/tmp/pids/thin.pid")
17
17
  end
18
+
19
+ def self.alive?(pid)
20
+ begin
21
+ Process.getpgid( pid.to_i )
22
+ true
23
+ rescue Errno::ESRCH
24
+ false
25
+ end
26
+ end
18
27
  end
@@ -6,6 +6,7 @@ require 'brisk/server/brisk_request_helper'
6
6
  require 'brisk/server/server'
7
7
  require 'brisk/server/site'
8
8
  require 'brisk/server/pid'
9
+ require 'net/http'
9
10
 
10
11
  class AppProxy < Rack::Proxy
11
12
 
@@ -44,6 +45,7 @@ class AppProxy < Rack::Proxy
44
45
  # Boot up the server
45
46
  Server.start(valet_site_path)
46
47
 
48
+ # Check if proccess is up and running
47
49
  started = Server.is_started(valet_site_path)
48
50
 
49
51
  # Write the pid to a file so we can delete it later on
@@ -53,11 +55,23 @@ class AppProxy < Rack::Proxy
53
55
  Site.write_site(valet_home_path, site)
54
56
  end
55
57
 
56
- sleep(2)
58
+ run env
59
+ end
60
+
61
+ def run(env, counter = 0)
57
62
 
58
- # # Set the host to the server we just started
59
- env["HTTP_HOST"] = "localhost:3000"
63
+ raise Exception.new "Brisk is not able to run the server.. Connection refused" if counter == 10
60
64
 
61
- env
65
+ sleep(0.5)
66
+ uri = URI('http://localhost:3000')
67
+
68
+ begin
69
+ # Check if the server is up and running. Find a cleaner way to do this
70
+ Net::HTTP.get(uri)
71
+ env['HTTP_HOST'] = 'localhost:3000'
72
+ return env
73
+ rescue Errno::ECONNREFUSED
74
+ run(env, counter + 1)
75
+ end
62
76
  end
63
77
  end
@@ -22,9 +22,12 @@ class Server
22
22
  end
23
23
 
24
24
  def self.is_started(path, counter = 0)
25
- sleep(1)
26
25
  if Pid.exists?(path)
27
- return true
26
+ sleep(0.5)
27
+ pid = Pid.read(path)
28
+ if Pid.alive?(pid)
29
+ return true
30
+ end
28
31
  end
29
32
 
30
33
  is_started(path, counter + 1)
data/lib/brisk/thin.rb CHANGED
@@ -3,13 +3,14 @@ require 'colorize'
3
3
  class Thin
4
4
 
5
5
  def self.install
6
- unless system "gem list -i thin > /dev/null"
7
- system "gem install thin > /dev/null"
6
+ unless is_installed?
8
7
 
9
- if $? == 0
8
+
9
+ if download
10
10
  puts "Successfuly installed thin".colorize(:green)
11
11
  else
12
12
  puts "Something went wrong while installing thin. The process gets stopped".colorize(:red)
13
+ exit
13
14
  end
14
15
  end
15
16
 
@@ -24,6 +25,18 @@ class Thin
24
25
  end
25
26
  end
26
27
 
28
+ def self.download
29
+ system "gem install thin > /dev/null"
30
+
31
+ $? == 0
32
+ end
33
+
34
+ def self.is_installed?
35
+ system "gem list -i thin > /dev/null"
36
+
37
+ $? == 0
38
+ end
39
+
27
40
  def self.restart
28
41
  stop
29
42
 
data/lib/brisk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brisk
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-14 00:00:00.000000000 Z
11
+ date: 2016-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler