Class: Singularity::Deployer
- Inherits:
-
Object
- Object
- Singularity::Deployer
- Defined in:
- lib/singularity.rb
Instance Method Summary collapse
- #deploy ⇒ Object
-
#initialize(uri, file, release) ⇒ Deployer
constructor
A new instance of Deployer.
- #is_paused ⇒ Object
Constructor Details
#initialize(uri, file, release) ⇒ Deployer
Returns a new instance of Deployer.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/singularity.rb', line 17 def initialize(uri, file, release) @uri = uri @file = file @release = release @config = ERB.new(open(file).read) @r = Request.new @r.release = @release @data = JSON.parse(@config.result(@r.get_binding)) print @data['id'] end |
Instance Method Details
#deploy ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/singularity.rb', line 39 def deploy begin if is_paused() puts " PAUSED, SKIPPING".yellow return else # create or update the request resp = RestClient.post "#{@uri}/api/requests", @data.to_json, :content_type => :json end # deploy the request @data['requestId'] = @data['id'] @data['id'] = "#{@release}.#{Time.now.to_i}" deploy = { 'deploy' => @data, 'user' => `whoami`.chomp, 'unpauseOnSuccessfulDeploy' => false } resp = RestClient.post "#{@uri}/api/deploys", deploy.to_json, :content_type => :json puts " DEPLOYED".green rescue Exception => e puts " #{e.response}".red end end |
#is_paused ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/singularity.rb', line 29 def is_paused begin resp = RestClient.get "#{@uri}/api/requests/request/#{@data['id']}" JSON.parse(resp)['state'] == 'PAUSED' rescue print " CREATING...".blue false end end |