pampa 2.0.14 → 2.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pampa.rb +42 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8627e0b3e3f9d923c9dc750fde056078bfd202a74e3abd36eecfa27566c93f3
|
4
|
+
data.tar.gz: 27990d2b64539c229974280e5d80b630b7e6dfb05b4b6533ef8976031e791a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71fb9a3ab3965c5aa591412c358ff6074b12d9e7ff6b8409d941ac28e42ba2ccb85288f1987a20758fd81c795d22323c597c2f15be040d5e1b628fed008aaecb
|
7
|
+
data.tar.gz: e33cfc7bca76c0a3031c4bfdc96417cfba6fadbcf7593b499a9eb2b5cefd996371b05548f159149ff2d204ae8035c524ac77c2dadbb081bde93693f0e64da1d9
|
data/lib/pampa.rb
CHANGED
@@ -358,7 +358,7 @@ module BlackStack
|
|
358
358
|
l.done
|
359
359
|
# kill all ruby processes except this one
|
360
360
|
l.logs("Killing all Ruby processes except this one... ")
|
361
|
-
node.
|
361
|
+
node.kill_workers()
|
362
362
|
l.done
|
363
363
|
# rename any existing folder ~/code/pampa to ~/code/pampa.<current timestamp>.
|
364
364
|
l.logs("Renaming old folder... ")
|
@@ -383,8 +383,23 @@ module BlackStack
|
|
383
383
|
# run the worker
|
384
384
|
# add these parameters for debug: debug=yes pampa=~/code/pampa/lib/pampa.rb
|
385
385
|
l.logs "Running worker #{worker.id}... "
|
386
|
-
|
387
|
-
|
386
|
+
|
387
|
+
# write bash command to initialize bash file
|
388
|
+
s = "echo \"
|
389
|
+
export RUBYLIB=$HOME/code/mysaas;
|
390
|
+
source $HOME/.profile;
|
391
|
+
source /usr/local/rvm/scripts/rvm;
|
392
|
+
cd ~/code/mysaas; rvm install 3.1.2;
|
393
|
+
rvm --default use 3.1.2;
|
394
|
+
cd #{BlackStack::Pampa.working_directory};
|
395
|
+
nohup ruby #{worker_filename} id=#{worker.id} config=#{self.config_filename} >/dev/null 2>&1 &
|
396
|
+
\" > #{BlackStack::Pampa.working_directory}/#{worker.id}.sh"
|
397
|
+
node.exec(s, false);
|
398
|
+
|
399
|
+
#s = "nohup bash #{BlackStack::Pampa.working_directory}/worker.sh >/dev/null 2>&1 &"
|
400
|
+
s = "bash #{BlackStack::Pampa.working_directory}/#{worker.id}.sh"
|
401
|
+
node.exec(s, false);
|
402
|
+
|
388
403
|
l.done
|
389
404
|
}
|
390
405
|
# disconnect the node
|
@@ -418,7 +433,7 @@ module BlackStack
|
|
418
433
|
l.done
|
419
434
|
# kill all ruby processes except this one
|
420
435
|
l.logs("Killing all Ruby processes except this one... ")
|
421
|
-
node.
|
436
|
+
node.kill_workers()
|
422
437
|
l.done
|
423
438
|
# run the number of workers specified in the configuration of the Pampa module.
|
424
439
|
node.workers.each { |worker|
|
@@ -429,10 +444,18 @@ module BlackStack
|
|
429
444
|
l.logs "Running worker #{worker.id}... "
|
430
445
|
|
431
446
|
# write bash command to initialize bash file
|
432
|
-
s = "echo \"
|
447
|
+
s = "echo \"
|
448
|
+
export RUBYLIB=$HOME/code/mysaas;
|
449
|
+
source $HOME/.profile;
|
450
|
+
source /usr/local/rvm/scripts/rvm;
|
451
|
+
cd ~/code/mysaas; rvm install 3.1.2;
|
452
|
+
rvm --default use 3.1.2;
|
453
|
+
cd #{BlackStack::Pampa.working_directory};
|
454
|
+
nohup ruby #{worker_filename} id=#{worker.id} config=#{self.config_filename} >/dev/null 2>&1 &
|
455
|
+
\" > #{BlackStack::Pampa.working_directory}/#{worker.id}.sh"
|
456
|
+
#binding.pry
|
433
457
|
node.exec(s, false);
|
434
|
-
|
435
|
-
s = "nohup bash #{BlackStack::Pampa.working_directory}/worker.sh >/dev/null 2>&1 &"
|
458
|
+
s = "nohup bash #{BlackStack::Pampa.working_directory}/#{worker.id}.sh >/dev/null 2>&1 &"
|
436
459
|
node.exec(s, false);
|
437
460
|
|
438
461
|
l.done
|
@@ -469,7 +492,7 @@ module BlackStack
|
|
469
492
|
l.done
|
470
493
|
# kill all ruby processes except this one
|
471
494
|
l.logs("Killing all Ruby processes except this one... ")
|
472
|
-
node.
|
495
|
+
node.kill_workers()
|
473
496
|
l.done
|
474
497
|
# disconnect the node
|
475
498
|
l.logs("Disconnecting... ")
|
@@ -490,7 +513,8 @@ module BlackStack
|
|
490
513
|
# connect the node
|
491
514
|
n.connect()
|
492
515
|
# get the time of the last time the worker wrote the log file
|
493
|
-
|
516
|
+
code = "cat #{BlackStack::Pampa.working_directory}/worker.#{worker_id}.log | tail -n 1 | cut -b1-19"
|
517
|
+
s = n.exec(code, false).to_s.strip
|
494
518
|
# run bash command to get the difference in minutes beteen now and the last time the worker wrote the log file
|
495
519
|
s = n.exec("echo \"$(($(date +%s) - $(date -d '#{s}' +%s))) / 60\" | bc", false).to_s.strip
|
496
520
|
# disconnect the node
|
@@ -592,6 +616,15 @@ module BlackStack
|
|
592
616
|
end
|
593
617
|
ret
|
594
618
|
end
|
619
|
+
# kill all workers
|
620
|
+
def kill_workers()
|
621
|
+
self.workers.each do |worker|
|
622
|
+
self.kill_worker(worker.id)
|
623
|
+
end
|
624
|
+
end
|
625
|
+
def kill_worker(worker_id)
|
626
|
+
self.exec("kill -9 $(ps -ef | grep \"ruby worker.rb id=#{worker_id}\" | grep -v grep | awk '{print $2}')", false)
|
627
|
+
end
|
595
628
|
end # class Node
|
596
629
|
|
597
630
|
# stub job class
|
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.
|
4
|
+
version: 2.0.15
|
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-12-
|
11
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|