pampa 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pampa.rb +51 -8
  3. metadata +26 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89133fe1804c0b0b2d06075aff1209d3cc9cff289e94845478825a08e7d963b6
4
- data.tar.gz: cd87b3364b2279bf7ea1c33d8b122ce76d21799dc3128bdb5a5c24c43b6b33b0
3
+ metadata.gz: 69ee20e63e239cd70fb18bf3cc6a8425e9badce48360a31d1b7bdfc029765ade
4
+ data.tar.gz: a8f93a2fdd1bae37ce2f9427423f48f64259079086509e52fbd201b8e567bf03
5
5
  SHA512:
6
- metadata.gz: d5c86a14cb767a036908b44ee7786342cb598cf150fa6af3ee602f52315a70887fc54fb8b02547825d5cb3118e5f9ca10775e802f54ffa56d4681bd4777764cb
7
- data.tar.gz: 8c16e8077270368087b08554ef5d2caa432f7a8efbacbd129a4e3023fd0e221a9eafe5d17ec53b967d7041c0e46dec557c61ddac464aa39371e269ee8919b41a
6
+ metadata.gz: a81ace1a17588363728f70b705455ede1a2bc970ae5ebba80be9a41ae51e745a1947fc66fdd69ecf577c267e885d4dbad167da593cceba34eb79f1dcaef6df6c
7
+ data.tar.gz: fe314f7ef5414680473f5710bf0fd4ff3eb670eb2d85e613099e43149de1d7598e3cabee0bff81274550badeea77219ee5920c211f176b5cac2947b382421a3a
data/lib/pampa.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'sequel'
2
2
  require 'blackstack-core'
3
3
  require 'blackstack-nodes'
4
+ require 'blackstack-deployer'
4
5
  require 'simple_command_line_parser'
5
6
  require 'simple_cloud_logging'
6
7
 
@@ -26,6 +27,10 @@ module BlackStack
26
27
  @@logger
27
28
  end
28
29
 
30
+ def self.set_logger(l)
31
+ @@logger = l
32
+ end
33
+
29
34
  # return the log filename.
30
35
  def self.log_filename()
31
36
  @@log_filename
@@ -44,6 +49,8 @@ module BlackStack
44
49
  # add a node to the cluster.
45
50
  def self.add_node(h)
46
51
  @@nodes << BlackStack::Pampa::Node.new(h)
52
+ # add to deployer too, in order to run deployment.
53
+ BlackStack::Deployer.add_nodes(h)
47
54
  end # def self.add_node(h)
48
55
 
49
56
  # add an array of nodes to the cluster.
@@ -333,14 +340,7 @@ module BlackStack
333
340
  # run the worker
334
341
  # add these parameters for debug: debug=yes pampa=~/code/pampa/lib/pampa.rb
335
342
  l.logs "Running worker #{worker.id}... "
336
- s = "
337
- source /home/#{node.ssh_username}/.rvm/scripts/rvm >/dev/null 2>&1;
338
- rvm install 3.1.2 >/dev/null 2>&1;
339
- rvm --default use 3.1.2 >/dev/null 2>&1;
340
- cd /home/#{node.ssh_username}/pampa >/dev/null 2>&1;
341
- export RUBYLIB=/home/#{node.ssh_username}/pampa >/dev/null 2>&1;
342
- nohup ruby worker.rb id=#{worker.id} config=~/pampa/config.rb >/dev/null 2>&1 &
343
- "
343
+ s = "nohup ruby worker.rb id=#{worker.id} config=~/pampa/config.rb >/dev/null 2>&1 &"
344
344
  node.exec(s, false)
345
345
  l.done
346
346
  }
@@ -352,6 +352,48 @@ module BlackStack
352
352
  } # @@nodes.each do |node|
353
353
  end
354
354
 
355
+ # connect the nodes via ssh.
356
+ # kill all Ruby processes except this one.
357
+ # run the number of workers specified in the configuration of the Pampa module.
358
+ # return an array with the IDs of the workers.
359
+ #
360
+ def self.start()
361
+ # validate: the connection string is not nil
362
+ raise "The connection string is nil" if @@connection_string.nil?
363
+ # validate: the connection string is not empty
364
+ raise "The connection string is empty" if @@connection_string.empty?
365
+ # validate: the connection string is not blank
366
+ raise "The connection string is blank" if @@connection_string.strip.empty?
367
+ # getting logger
368
+ l = self.logger()
369
+ # iterate the nodes
370
+ @@nodes.each { |node|
371
+ l.logs("node:#{node.name()}... ")
372
+ # connect the node
373
+ l.logs("Connecting... ")
374
+ node.connect()
375
+ l.done
376
+ # kill all ruby processes except this one
377
+ l.logs("Killing all Ruby processes except this one... ")
378
+ node.exec("ps ax | grep ruby | grep -v grep | grep -v #{Process.pid} | cut -b3-7 | xargs -t kill;", false)
379
+ l.done
380
+ # run the number of workers specified in the configuration of the Pampa module.
381
+ node.workers.each { |worker|
382
+ # run the worker
383
+ # add these parameters for debug: debug=yes pampa=~/code/pampa/lib/pampa.rb
384
+ l.logs "Running worker #{worker.id}... "
385
+ s = "nohup ruby worker.rb id=#{worker.id} config=~/pampa/config.rb >/dev/null 2>&1 &"
386
+ node.exec(s, false)
387
+ l.done
388
+ }
389
+ # disconnect the node
390
+ l.logs("Disconnecting... ")
391
+ node.disconnect()
392
+ l.done
393
+ l.done
394
+ } # @@nodes.each do |node|
395
+ end
396
+
355
397
  # connect the nodes via ssh.
356
398
  # kill all Ruby processes except this one.
357
399
  #
@@ -645,6 +687,7 @@ module BlackStack
645
687
  AND #{self.field_time.to_s} < CURRENT_TIMESTAMP() - INTERVAL '#{self.max_job_duration_minutes.to_i} minutes'
646
688
  AND #{self.field_id.to_s} IS NOT NULL
647
689
  AND #{self.field_end_time.to_s} IS NULL
690
+ AND COALESCE(#{self.field_times.to_s},0) < #{self.max_try_times.to_i}
648
691
  LIMIT #{n}
649
692
  "
650
693
  DB[q].all
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pampa
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-25 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -56,20 +56,40 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 1.2.10
59
+ version: 1.2.11
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 1.2.10
62
+ version: 1.2.11
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 1.2.10
69
+ version: 1.2.11
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 1.2.10
72
+ version: 1.2.11
73
+ - !ruby/object:Gem::Dependency
74
+ name: blackstack-deployer
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: 1.2.24
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.2.24
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.2.24
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.2.24
73
93
  - !ruby/object:Gem::Dependency
74
94
  name: simple_command_line_parser
75
95
  requirement: !ruby/object:Gem::Requirement