herdst_worker 0.1.1 → 0.1.6

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
  SHA256:
3
- metadata.gz: c9d5a5ffa6aa3b5fcfeae78e88aee46567078ed0c34c751f4d0396a523debbb8
4
- data.tar.gz: 52ce41c7f10e65a8dea9b7e3afb3163ea8604bad592bc3b5606b5dc1890b70b5
3
+ metadata.gz: dd3d83d5c9eed1daf41c0c8e9da9da90bce24f9abcf9e8e244b7c8da1115947c
4
+ data.tar.gz: 127e7147df4a561a8f1fcb6d9030e679d46e044e942333ae8e94eab2d018df0d
5
5
  SHA512:
6
- metadata.gz: 48b2860290db0874e6da4f037511f9c4634df933154a771c5c9d3f535e8f8887e2bd91ea7dd8f3983ed1406dbf0318d32deca935f8891cc1e38d31bc3e97ff53
7
- data.tar.gz: 398ebb6a28106cf7693e7b6fc55c8dd0eba03f29c36032c00da88466ab076bbb8712c78652c26c36e70a7f0668d9b5145d72c5bb4ab026eed18c11141bce6635
6
+ metadata.gz: d5eff402b28ecb69fa5a084ee36d624a6d1f33b42345d6137f14df98069103221ccbce40582c4b95c1d13eb277cd7665576d4ee16d770fa9bd4b0b71f52ddef3
7
+ data.tar.gz: a1c1648befbdb86e76d76d39d59a090ccfc1a93c477c200637f8ec738b0e356c077d84c770501723cd65ac95dc7a430c15dd1a8fdb8782e6b45be83d92a5e661
data/bin/herdst_worker CHANGED
@@ -1,18 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- args = Hash[ ARGV.flat_map { |s| s.scan(/--?([^=\s]+)(?:=(\S+))?/) } ]
3
+ args = ARGV
4
+ .flat_map { |s| s.scan(/--?([^=\s]+)(?:=(\S+))?/) }
5
+ .select { |i| i[1] != "" }
4
6
 
5
- application_name = args["name"]
6
- application_file = args["application"] || "application.rb"
7
+ arg_pair = Hash[ args ]
8
+ application_name = arg_pair["name"]
9
+ application_file = arg_pair["application"] || "application.rb"
7
10
  application_path = "#{Dir.pwd}/#{application_file}"
8
- application_env = args["env"] || "production"
9
- queue_enabled = args["queue_enabled"] == "false" ? false : true
11
+ application_env = arg_pair["env"] || "production"
12
+ queue_enabled = arg_pair["queue_enabled"] == "false" ? false : true
10
13
 
11
- raise "Please specify a name for the application E.g. --name=[name]" unless application_name.present?
14
+ raise "Please specify a name for the application E.g. --name=[name]" unless application_name
12
15
 
13
16
  require_relative "../lib/herdst_worker"
14
17
 
15
- application_instance = HerdstWorker::Application.new(application_env, queue_enabled)
18
+ application_instance = HerdstWorker::Application.new(application_env, application_name, queue_enabled)
16
19
 
17
20
  require_relative application_path
18
21
 
@@ -4,25 +4,29 @@ module HerdstWorker
4
4
 
5
5
 
6
6
  def self.setup(app)
7
- db_config = app.config_for(:database)
8
-
9
- if app.config.is_dev?
10
- ActiveRecord::Base.logger = app.logger.activerecord
7
+ begin
8
+ db_config = app.config_for(:database)
9
+
10
+ if app.config.is_dev?
11
+ ActiveRecord::Base.logger = app.logger.activerecord
12
+ end
13
+
14
+ ActiveRecord::Base.default_timezone = :utc
15
+ ActiveRecord::Base.establish_connection(
16
+ adapter: db_config[:adapter],
17
+ encoding: db_config[:encoding],
18
+ charset: db_config[:charset],
19
+ collation: db_config[:collation],
20
+ pool: db_config[:pool],
21
+ host: db_config[:host],
22
+ username: db_config[:username],
23
+ password: db_config[:password],
24
+ database: db_config[:database]
25
+ )
26
+ ActiveRecord::Base.connection.enable_query_cache!
27
+ rescue Exception => ex
28
+ app.logger.error ex.message
11
29
  end
12
-
13
- ActiveRecord::Base.default_timezone = :utc
14
- ActiveRecord::Base.establish_connection(
15
- adapter: db_config[:adapter],
16
- encoding: db_config[:encoding],
17
- charset: db_config[:charset],
18
- collation: db_config[:collation],
19
- pool: db_config[:pool],
20
- host: db_config[:host],
21
- username: db_config[:username],
22
- password: db_config[:password],
23
- database: db_config[:database]
24
- )
25
- ActiveRecord::Base.connection.enable_query_cache!
26
30
  end
27
31
 
28
32
 
@@ -7,16 +7,20 @@ module HerdstWorker
7
7
 
8
8
 
9
9
  def self.setup(app)
10
- environment = app.config.metadata[:DEPLOYMENT_ENV]
11
- release = app.config.metadata[:RELEASE_VERSION]
12
- sentry_key = app.config.metadata[:SENTRY_KEY]
13
-
14
- Raven.configure do |config|
15
- config.current_environment = environment
16
- config.release = release
17
- config.dsn = sentry_key if sentry_key
18
- config.environments = ["preview", "production"]
19
- config.async = lambda { |event| Thread.new { Raven.send_event(event) } }
10
+ begin
11
+ environment = app.config.metadata[:DEPLOYMENT_ENV]
12
+ release = app.config.metadata[:RELEASE_VERSION]
13
+ sentry_key = app.config.metadata[:SENTRY_KEY]
14
+
15
+ Raven.configure do |config|
16
+ config.current_environment = environment
17
+ config.release = release
18
+ config.dsn = sentry_key if sentry_key
19
+ config.environments = ["preview", "production"]
20
+ config.async = lambda { |event| Thread.new { Raven.send_event(event) } }
21
+ end
22
+ rescue Exception => ex
23
+ app.logger.error ex.message
20
24
  end
21
25
  end
22
26
 
@@ -24,7 +24,11 @@ module HerdstWorker
24
24
  begin
25
25
  self.reload!
26
26
  rescue Exception => ex
27
- raise ex unless self.is_prod?
27
+ if self.is_prod?
28
+ puts "Failed to load metadata: #{ex.message}"
29
+ else
30
+ raise ex
31
+ end
28
32
  end
29
33
  end
30
34
 
@@ -1,3 +1,3 @@
1
1
  module HerdstWorker
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herdst_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herd.St
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport