mutx 0.1.37 → 0.1.38

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: 63007fc4f35954e41261249bb328f1ca99cc0e1f
4
- data.tar.gz: 2268f81f250d391999c10be2bd4e1c744efc3e6c
3
+ metadata.gz: fe66af70096105090277bc10778164c582aafa30
4
+ data.tar.gz: 7bd12e83fd2857215abe904dde84e56d46bdbbac
5
5
  SHA512:
6
- metadata.gz: 1cd7fac29d206a797726eec546759253cc143c80b601e14c36745962a74d491c0f54f672281b79c8f90722840fed7b18115fe87f12839ef6958df7328192944f
7
- data.tar.gz: 3ccc106731aede21c033da97f57754517c86e4730eb4291716c23eea761e625d2140d85833daa37eef19317bf273c8c88163b510484ec0465cc137fc0bc4c9ef
6
+ metadata.gz: 118bb88afa20e36a78d4144a7a09264d6dc3c2ff0bda5dd1f4fee4f4370804c9ebed0575ff3fc55894b41e8f44afd53876bb47da048f1392a70f635715c83d8d
7
+ data.tar.gz: 4e7267299c87bd0b293dd79bcc3b3edf6847dfedc280836caf6da14569252a72c3f1775755ec52a54e6b7fc5ece4c8788a65625f4d75b2f02dd931750c4103a5
@@ -13,60 +13,71 @@ module Mutx
13
13
  recurrence { minutely(1) }
14
14
 
15
15
  def perform
16
+ running_task = []
17
+ running_task = Mutx::Database::MongoConnector.running_now
16
18
 
17
19
  puts "######### STARTING CRON ##########"
18
- @days = [:mo,:tu,:we,:th,:fr,:sa,:su]
19
- @today = day_name #name of today
20
20
 
21
- #BEGIN# Select only cronned tasks that last_exec_time is OK to run
22
- cron_tasks = []
23
- cron_tasks_list = Mutx::Database::MongoConnector.cron_tasks
21
+ if running_task.eql? []
24
22
 
25
- puts "#{cron_tasks_list.size} cronned task searched"
23
+ @days = [:mo,:tu,:we,:th,:fr,:sa,:su]
24
+ @today = day_name #name of today
26
25
 
27
- cron_tasks_list.select{|line| cron_tasks << line if (((Time.now.utc - line[:last_exec_time].utc) + 1) >= (line[:cron_time].to_i * 60))}
28
- cron_tasks_list = []
29
- cron_tasks_list = cron_tasks
30
- puts "#{cron_tasks_list.size} POSSIBLE cronned task on time to run"
31
- #END# Select only cronned tasks that last_exec_time is OK to run
26
+ #BEGIN# Select only cronned tasks that last_exec_time is OK to run
27
+ cron_tasks = []
28
+ cron_tasks_list = Mutx::Database::MongoConnector.cron_tasks
32
29
 
33
- #BEGIN# REMOVING POSSIBLE DUPLICATED TASKS
34
- cron_tasks_list_aux = []
35
- cron_tasks_list_aux = cron_tasks_list
36
- cron_tasks_list = []
37
- cron_tasks_list = cron_tasks_list_aux.uniq { |line| [line[:name]].join(":") }
30
+ puts "#{cron_tasks_list.size} cronned task searched"
38
31
 
39
- puts
40
- puts "REMOVING DUPLICATED TASKS WITH SAME NAME" if !cron_tasks_list_aux.size.eql? cron_tasks_list.size
41
- puts "#{cron_tasks_list.size} cronned task after removing possible duplicated tasks"
42
- #END# REMOVING POSSIBLE DUPLICATED TASKS
43
-
44
- #BEGIN#Check if task is running or started
45
- cron_tasks = []
46
- cron_tasks_list.select{|line| cron_tasks << line if ((Mutx::Database::MongoConnector.running_for_task line[:name]) && (Mutx::Database::MongoConnector.only_started_for_task line[:name]) && (Mutx::Database::MongoConnector.only_running_for_task line[:name])).eql? []}
47
- cron_tasks_list = []
48
- cron_tasks_list = cron_tasks
49
- puts "#{cron_tasks_list.size} cronned task ready to run (not running or started)"
50
- #END#Check if task is running or started
51
-
52
- # TASK must be right on time to run and unique
53
- cron_tasks_list.each do |task|
54
- @@now_time = Time.now.hour.to_s+":"+Time.now.min.to_s
55
- @@now_time = ("0" + @@now_time.match(/\d*/).to_s + ":" + @@now_time.match(/\:(\d*)/)[1].to_s) if @@now_time.match(/(\d*)/)[1].size.eql? 1
56
- @@now_time = (@@now_time.match(/\d*/).to_s + ":0" + @@now_time.match(/\:(\d*)/)[1].to_s) if @@now_time.match(/\:(\d*)/)[1].size.eql? 1
57
- @@last_exec_time = nil
58
- @@last_exec_time = task[:last_exec_time]
59
- # Update last_exec_time before to run (because this task is OK to run)
60
- Mutx::API::Tasks.cron_update task if (((Time.now.utc - @@last_exec_time.utc) + 1) >= (task[:cron_time].to_i * 60))
61
- @none_day = true
62
-
63
- sleep 1
64
- validate_and_execute task
65
-
66
- end#cron_task
67
-
68
- Mutx::Database::MongoConnector.force_close
69
- puts "######### ENDING CRON ##########"
32
+ cron_tasks_list.select{|line| cron_tasks << line if (((Time.now.utc - line[:last_exec_time].utc) + 1) >= (line[:cron_time].to_i * 60))}
33
+ cron_tasks_list = []
34
+ cron_tasks_list = cron_tasks
35
+ puts "#{cron_tasks_list.size} POSSIBLE cronned task on time to run"
36
+ #END# Select only cronned tasks that last_exec_time is OK to run
37
+
38
+ #BEGIN# REMOVING POSSIBLE DUPLICATED TASKS
39
+ cron_tasks_list_aux = []
40
+ cron_tasks_list_aux = cron_tasks_list
41
+ cron_tasks_list = []
42
+ cron_tasks_list = cron_tasks_list_aux.uniq { |line| [line[:name]].join(":") }
43
+
44
+ puts
45
+ puts "REMOVING DUPLICATED TASKS WITH SAME NAME" if !cron_tasks_list_aux.size.eql? cron_tasks_list.size
46
+ puts "#{cron_tasks_list.size} cronned task after removing possible duplicated tasks"
47
+ #END# REMOVING POSSIBLE DUPLICATED TASKS
48
+
49
+ #BEGIN#Check if task is running or started
50
+ cron_tasks = []
51
+ cron_tasks_list.select{|line| cron_tasks << line if ((Mutx::Database::MongoConnector.running_for_task line[:name]) && (Mutx::Database::MongoConnector.only_started_for_task line[:name]) && (Mutx::Database::MongoConnector.only_running_for_task line[:name])).eql? []}
52
+ cron_tasks_list = []
53
+ cron_tasks_list = cron_tasks
54
+ puts "#{cron_tasks_list.size} cronned task ready to run (not running or started)"
55
+ #END#Check if task is running or started
56
+
57
+ # TASK must be right on time to run and unique
58
+ cron_tasks_list.each do |task|
59
+ @@now_time = Time.now.hour.to_s+":"+Time.now.min.to_s
60
+ @@now_time = ("0" + @@now_time.match(/\d*/).to_s + ":" + @@now_time.match(/\:(\d*)/)[1].to_s) if @@now_time.match(/(\d*)/)[1].size.eql? 1
61
+ @@now_time = (@@now_time.match(/\d*/).to_s + ":0" + @@now_time.match(/\:(\d*)/)[1].to_s) if @@now_time.match(/\:(\d*)/)[1].size.eql? 1
62
+ @@last_exec_time = nil
63
+ @@last_exec_time = task[:last_exec_time]
64
+ # Update last_exec_time before to run (because this task is OK to run)
65
+ Mutx::API::Tasks.cron_update task if (((Time.now.utc - @@last_exec_time.utc) + 1) >= (task[:cron_time].to_i * 60))
66
+ @none_day = true
67
+
68
+ sleep 1
69
+ validate_and_execute task
70
+
71
+ end#cron_task
72
+
73
+ Mutx::Database::MongoConnector.force_close
74
+ puts "######### ENDING CRON ##########"
75
+ else ## si hay algo corriendo deja pasar toda la ejecucion hasta que finalice
76
+ puts
77
+ puts "HAY EJECUCIONES EN RUNNING O STARTED, SE ESPERA A QUE TERMINEN..."
78
+ puts
79
+ puts "######### ENDING CRON ##########"
80
+ end
70
81
 
71
82
  end #perform
72
83
 
data/lib/mutx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mutx
2
- VERSION = "0.1.37"
2
+ VERSION = "0.1.38"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.37
4
+ version: 0.1.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor