monitored_process 0.0.4 → 0.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: 1f2c256a81987d5ccea603a1e2734a3a4fd903a0
4
- data.tar.gz: 2ee225057901afaaab5fe03bcdcf878ea11ccbeb
3
+ metadata.gz: 81a7b19cb2168d06393f937a858672b3a767129e
4
+ data.tar.gz: d562ef84ae8871341b74b021821f91d7648c8826
5
5
  SHA512:
6
- metadata.gz: 5642460d1c071c1c46637863694d25dc30556f9f3559417d383658a52f8869b04c2d05f54700a8b1776c72204ed2e06430df81a97bff7f53b2c1943c08d79b45
7
- data.tar.gz: bb8a2fee836afd58c3e6d706a8c5a7a681de519bfa512c67fa05feaadbe43041bae81f90f3a98eb0704bc4c227678dffaa08d908bbbc5bf484ca9d27e460cc38
6
+ metadata.gz: b8efd1b7987469750dadf9ffd4808c976709354dee3a4a323792f98a0d95937389186e5434a4d2a1795a1631d1006ddebc8a18aca3819f7991d344adc603c94b
7
+ data.tar.gz: 2a60464efb7d660b3ea72930b55e2cf0c825f8d063126e5b306d747e0f68fc193bf4454d4acb64797f778c9a10c5352408aa15ddfca52df769a84595b1113814
@@ -9,6 +9,11 @@ class MonitoredProcessInstallGenerator < Rails::Generators::Base
9
9
  migration_template 'create_monitored_processes.rb', 'db/migrate/create_monitored_processes.rb'
10
10
  end
11
11
 
12
+ def copy_mailer_templates
13
+ copy_file 'monitored_process_mailer.rb', 'app/mailers/monitored_process_mailer.rb'
14
+ copy_file 'process_execution_result_email.html.erb', 'app/views/monitored_process_mailer/process_execution_result_email.html.erb'
15
+ end
16
+
12
17
  def self.next_migration_number(dirname)
13
18
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
14
19
  end
@@ -0,0 +1,23 @@
1
+ class MonitoredProcessMailer < ActionMailer::Base
2
+ default from: Rails.application.config.monitored_processes_email_from
3
+
4
+ def process_execution_result_email(monitored_process)
5
+ return if Rails.application.config.monitored_processes_notificacion_emails.blank? or monitored_process.blank?
6
+
7
+ email_to = Rails.application.config.monitored_processes_notificacion_emails
8
+ subject = "[#{Rails.env}] - #{monitored_process.name} - "
9
+ case monitored_process.state
10
+ when MonitoredProcess::Base::STATE[:running]
11
+ subject += "Is running"
12
+ when MonitoredProcess::Base::STATE[:finished]
13
+ subject += "Finished correcly!"
14
+ when MonitoredProcess::Base::STATE[:finished_with_errors]
15
+ subject += "Finished with some errors :("
16
+ end
17
+
18
+ @monitored_process = monitored_process
19
+
20
+ mail(to: email_to, subject: subject)
21
+ end
22
+
23
+ end
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ </head>
6
+ <body>
7
+ <h1>Hello,</h1>
8
+
9
+ <p>This automated mail is being sent to inform you on the <%= @monitored_process.name %> process.</p>
10
+
11
+ <p><strong>Process status:</strong> <%= MonitoredProcess::Base.translate_state(@monitored_process.state) %></p>
12
+ <p><strong>Output:</strong> <%= @monitored_process.console_output.gsub("\n", "<br />").html_safe %></p>
13
+ <% if !@monitored_process.error_description.blank? then %>
14
+ <p><strong>Errors:</strong> <%= @monitored_process.error_description %></p>
15
+ <% end %>
16
+
17
+ </body>
18
+ </html>
@@ -1,3 +1,3 @@
1
1
  module MonitoredProcess
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1"
3
3
  end
@@ -11,7 +11,7 @@ module MonitoredProcess
11
11
  validates_presence_of :name, :state, :pid
12
12
 
13
13
  def self.start_process
14
- p = MonitoredProcess.new
14
+ p = MonitoredProcess::Base.new
15
15
  p.name = self.to_s
16
16
  p.state = STATE[:running]
17
17
  p.pid = Process.pid
@@ -0,0 +1,23 @@
1
+ class MonitoredProcessMailer < ActionMailer::Base
2
+ default from: Rails.application.config.monitored_processes_email_from
3
+
4
+ def process_execution_result_email(monitored_process)
5
+ return if Rails.application.config.monitored_processes_notificacion_emails.blank? or monitored_process.blank?
6
+
7
+ email_to = Rails.application.config.monitored_processes_notificacion_emails
8
+ subject = "[#{Rails.env}] - #{monitored_process.name} - "
9
+ case monitored_process.state
10
+ when MonitoredProcess::Base::STATE[:running]
11
+ subject += "Is running"
12
+ when MonitoredProcess::Base::STATE[:finished]
13
+ subject += "Finished correcly!"
14
+ when MonitoredProcess::Base::STATE[:finished_with_errors]
15
+ subject += "Finished with some errors :("
16
+ end
17
+
18
+ @monitored_process = monitored_process
19
+
20
+ mail(to: email_to, subject: subject)
21
+ end
22
+
23
+ end
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ </head>
6
+ <body>
7
+ <h1>Hello,</h1>
8
+
9
+ <p>This automated mail is being sent to inform you on the <%= @monitored_process.name %> process.</p>
10
+
11
+ <p><strong>Process status:</strong> <%= MonitoredProcess::Base.translate_state(@monitored_process.state) %></p>
12
+ <p><strong>Output:</strong> <%= @monitored_process.console_output.gsub("\n", "<br />").html_safe %></p>
13
+ <% if !@monitored_process.error_description.blank? then %>
14
+ <p><strong>Errors:</strong> <%= @monitored_process.error_description %></p>
15
+ <% end %>
16
+
17
+ </body>
18
+ </html>
@@ -38,4 +38,7 @@ Rails.application.configure do
38
38
 
39
39
  # Raises error for missing translations
40
40
  # config.action_view.raise_on_missing_translations = true
41
+
42
+ config.monitored_processes_email_from = 'jmvallejo@gmail.com'
43
+ config.monitored_processes_notificacion_emails = 'jmvallejo@gmail.com'
41
44
  end
Binary file
@@ -11,3 +11,55 @@ DEPRECATION WARNING: `#timestamp` was called without specifying an option for `n
11
11
  SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150603215041"]]
12
12
   (0.8ms) commit transaction
13
13
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
14
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
15
+ Migrating to CreateMonitoredProcesses (20150604200359)
16
+  (0.1ms) begin transaction
17
+ DEPRECATION WARNING: `#timestamp` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /Users/juanmvallejo/Projects/gems/monitored_process/test/dummy/db/migrate/20150604200359_create_monitored_processes.rb:12)
18
+  (0.1ms) CREATE TABLE "monitored_processes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "state" integer, "pid" integer, "elapsed_seconds" integer, "elapsed_time" varchar, "console_output" text, "error_description" text, "created_at" datetime, "updated_at" datetime) 
19
+ SQLite3::SQLException: table "monitored_processes" already exists: CREATE TABLE "monitored_processes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "state" integer, "pid" integer, "elapsed_seconds" integer, "elapsed_time" varchar, "console_output" text, "error_description" text, "created_at" datetime, "updated_at" datetime)
20
+  (0.0ms) rollback transaction
21
+  (0.1ms) begin transaction
22
+ SQL (1.1ms) INSERT INTO "monitored_processes" ("name", "state", "pid", "console_output", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["name", "MonitoredProcess::Base"], ["state", 1], ["pid", 21618], ["console_output", ""], ["created_at", "2015-06-04 20:08:40.092746"], ["updated_at", "2015-06-04 20:08:40.092746"]]
23
+  (0.7ms) commit transaction
24
+  (0.1ms) begin transaction
25
+ SQL (0.4ms) UPDATE "monitored_processes" SET "state" = ?, "elapsed_seconds" = ?, "elapsed_time" = ?, "updated_at" = ? WHERE "monitored_processes"."id" = ? [["state", 2], ["elapsed_seconds", 5], ["elapsed_time", "00:00:05"], ["updated_at", "2015-06-04 20:08:45.889482"], ["id", 1]]
26
+  (0.6ms) commit transaction
27
+ DEPRECATION WARNING: `#deliver` is deprecated and will be removed in Rails 5. Use `#deliver_now` to deliver immediately or `#deliver_later` to deliver through Active Job. (called from send_status_email at /Users/juanmvallejo/Projects/gems/monitored_process/lib/monitored_process.rb:102)
28
+
29
+ MonitoredProcessMailer#process_execution_result_email: processed outbound mail in 0.7ms
30
+ MonitoredProcess::Base Load (0.2ms) SELECT "monitored_processes".* FROM "monitored_processes" ORDER BY "monitored_processes"."id" ASC LIMIT 1
31
+ DEPRECATION WARNING: `#deliver` is deprecated and will be removed in Rails 5. Use `#deliver_now` to deliver immediately or `#deliver_later` to deliver through Active Job. (called from send_status_email at /Users/juanmvallejo/Projects/gems/monitored_process/lib/monitored_process.rb:102)
32
+
33
+ MonitoredProcessMailer#process_execution_result_email: processed outbound mail in 0.9ms
34
+ MonitoredProcess::Base Load (0.2ms) SELECT "monitored_processes".* FROM "monitored_processes" ORDER BY "monitored_processes"."id" ASC LIMIT 1
35
+ DEPRECATION WARNING: `#deliver` is deprecated and will be removed in Rails 5. Use `#deliver_now` to deliver immediately or `#deliver_later` to deliver through Active Job. (called from send_status_email at /Users/juanmvallejo/Projects/gems/monitored_process/lib/monitored_process.rb:102)
36
+ Rendered monitored_process_mailer/process_execution_result_email.html.erb (2.0ms)
37
+
38
+ MonitoredProcessMailer#process_execution_result_email: processed outbound mail in 200.6ms
39
+
40
+ Sent mail to jmvallejo@gmail.com (8.7ms)
41
+ Date: Thu, 04 Jun 2015 15:11:48 -0500
42
+ From: jmvallejo@gmail.com
43
+ To: jmvallejo@gmail.com
44
+ Message-ID: <5570b104b52ec_547c3ff90205e6d8626de@Juans-MacBook-Pro.local.mail>
45
+ Subject: [development] - MonitoredProcess::Base - Finished correcly!
46
+ Mime-Version: 1.0
47
+ Content-Type: text/html;
48
+ charset=UTF-8
49
+ Content-Transfer-Encoding: 7bit
50
+
51
+ <!DOCTYPE html>
52
+ <html>
53
+ <head>
54
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
55
+ </head>
56
+ <body>
57
+ <h1>Hello,</h1>
58
+
59
+ <p>This automated mail is being sent to inform you on the MonitoredProcess::Base process.</p>
60
+
61
+ <p><strong>Process status:</strong> Finished</p>
62
+ <p><strong>Output:</strong> </p>
63
+
64
+ </body>
65
+ </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monitored_process
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Manuel Vallejo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,8 @@ files:
52
52
  - lib/generators/monitored_process_install/USAGE
53
53
  - lib/generators/monitored_process_install/monitored_process_install_generator.rb
54
54
  - lib/generators/monitored_process_install/templates/create_monitored_processes.rb
55
+ - lib/generators/monitored_process_install/templates/monitored_process_mailer.rb
56
+ - lib/generators/monitored_process_install/templates/process_execution_result_email.html.erb
55
57
  - lib/monitored_process.rb
56
58
  - lib/monitored_process/version.rb
57
59
  - lib/tasks/monitored_process_tasks.rake
@@ -61,7 +63,9 @@ files:
61
63
  - test/dummy/app/assets/stylesheets/application.css
62
64
  - test/dummy/app/controllers/application_controller.rb
63
65
  - test/dummy/app/helpers/application_helper.rb
66
+ - test/dummy/app/mailers/monitored_process_mailer.rb
64
67
  - test/dummy/app/views/layouts/application.html.erb
68
+ - test/dummy/app/views/monitored_process_mailer/process_execution_result_email.html.erb
65
69
  - test/dummy/bin/bundle
66
70
  - test/dummy/bin/rails
67
71
  - test/dummy/bin/rake
@@ -86,8 +90,7 @@ files:
86
90
  - test/dummy/config/routes.rb
87
91
  - test/dummy/config/secrets.yml
88
92
  - test/dummy/db/development.sqlite3
89
- - test/dummy/db/migrate/20150603215041_create_monitored_processes.rb
90
- - test/dummy/db/migrate/create_monitored_processes.rb
93
+ - test/dummy/db/migrate/20150604200359_create_monitored_processes.rb
91
94
  - test/dummy/db/schema.rb
92
95
  - test/dummy/db/test.sqlite3
93
96
  - test/dummy/log/development.log
@@ -128,7 +131,9 @@ test_files:
128
131
  - test/dummy/app/assets/stylesheets/application.css
129
132
  - test/dummy/app/controllers/application_controller.rb
130
133
  - test/dummy/app/helpers/application_helper.rb
134
+ - test/dummy/app/mailers/monitored_process_mailer.rb
131
135
  - test/dummy/app/views/layouts/application.html.erb
136
+ - test/dummy/app/views/monitored_process_mailer/process_execution_result_email.html.erb
132
137
  - test/dummy/bin/bundle
133
138
  - test/dummy/bin/rails
134
139
  - test/dummy/bin/rake
@@ -153,8 +158,7 @@ test_files:
153
158
  - test/dummy/config/secrets.yml
154
159
  - test/dummy/config.ru
155
160
  - test/dummy/db/development.sqlite3
156
- - test/dummy/db/migrate/20150603215041_create_monitored_processes.rb
157
- - test/dummy/db/migrate/create_monitored_processes.rb
161
+ - test/dummy/db/migrate/20150604200359_create_monitored_processes.rb
158
162
  - test/dummy/db/schema.rb
159
163
  - test/dummy/db/test.sqlite3
160
164
  - test/dummy/log/development.log
@@ -1,15 +0,0 @@
1
- class CreateMonitoredProcess1s < ActiveRecord::Migration
2
- def change
3
- create_table :monitored_processes do |t|
4
- t.string :name
5
- t.integer :state
6
- t.integer :pid
7
- t.integer :elapsed_seconds
8
- t.string :elapsed_time
9
- t.text :console_output
10
- t.text :error_description
11
-
12
- t.timestamps
13
- end
14
- end
15
- end