jets 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/jets.rb +4 -1
- data/lib/jets/booter.rb +13 -29
- data/lib/jets/commands/deploy.rb +8 -0
- data/lib/jets/core.rb +1 -2
- data/lib/jets/core_ext/kernel.rb +23 -0
- data/lib/jets/io.rb +14 -0
- data/lib/jets/logger.rb +24 -0
- data/lib/jets/ruby_server.rb +2 -1
- data/lib/jets/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba1ae625286077b458d497643590d72d83d10e800ce1d8fc1bf18599260501a0
|
4
|
+
data.tar.gz: cdccc52793152392901ae9c27e5bfbeafaccf49d4fc78fea70dc28feeda0d8ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ead8f6f9e01613c614e6815e25ad777413fb2222e07b065962a7ee3e33d19dad7dcb7fd9a158da57543ba9ec65c3634043081ea44636227a633d29dbb914035
|
7
|
+
data.tar.gz: 59a7f19c9e3486d68462f929d0ef93b54ec752edc4ae9b880bd535fd57d969370088a4053c4bf37cd0da63ed2b113ffe75b8804e6f7842da182c39a5b6223ace
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.6.6]
|
7
|
+
- improve puts handling: PR #15
|
8
|
+
|
6
9
|
## [0.6.5]
|
7
10
|
- fix prewarming after a deploy
|
8
11
|
|
data/Gemfile.lock
CHANGED
data/lib/jets.rb
CHANGED
@@ -44,13 +44,16 @@ module Jets
|
|
44
44
|
extend Core # root, logger, etc
|
45
45
|
|
46
46
|
autoload :RubyServer, "jets/ruby_server"
|
47
|
+
autoload :IO, "jets/io"
|
48
|
+
autoload :Logger, "jets/logger"
|
47
49
|
end
|
48
50
|
|
51
|
+
require "jets/core_ext/kernel"
|
52
|
+
|
49
53
|
$:.unshift(File.expand_path("../../vendor/lambdagem/lib", __FILE__))
|
50
54
|
require "lambdagem"
|
51
55
|
require "gems" # lambdagem dependency
|
52
56
|
|
53
|
-
|
54
57
|
# lazy loaded dependencies: depends what project. Mainly determined by Gemfile
|
55
58
|
# and config files.
|
56
59
|
if File.exist?("#{Jets.root}config/dynamodb.yml")
|
data/lib/jets/booter.rb
CHANGED
@@ -4,7 +4,7 @@ class Jets::Booter
|
|
4
4
|
def boot!(options={})
|
5
5
|
return if @booted
|
6
6
|
|
7
|
-
redirect_output
|
7
|
+
redirect_output
|
8
8
|
confirm_jets_project!
|
9
9
|
require_bundle_gems
|
10
10
|
Jets::Dotenv.load!
|
@@ -14,37 +14,21 @@ class Jets::Booter
|
|
14
14
|
@booted = true
|
15
15
|
end
|
16
16
|
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# AWS Lambda for natively supported languages prints to CloudWatch instead of
|
18
|
+
# mungling up the response. We'll redirect stdout to stderr to mimic AWS Lambda
|
19
|
+
# behavior.
|
19
20
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
|
21
|
+
# Also, for local use, printing to stdout can mangle up the response when piping
|
22
|
+
# the value to jq. For example:
|
23
|
+
#
|
24
|
+
# `jets call --local .. | jq`
|
25
|
+
#
|
26
|
+
# By redirecting stderr we can use jq safely.
|
27
|
+
#
|
28
|
+
def redirect_output
|
24
29
|
$stdout.sync = true
|
25
30
|
$stderr.sync = true
|
26
|
-
|
27
|
-
# Set both $stdout and $stdout to a StringIO object as a buffer.
|
28
|
-
# At the end of the request, write this buffer to the filesystem.
|
29
|
-
# In the node shim, read it back and write it to AWS Lambda logs.
|
30
|
-
#
|
31
|
-
# This allows using `puts` to write to CloudWatch.
|
32
|
-
$stdout = $stderr = StringIO.new # for ruby_server and AWS Lambda to capture log
|
33
|
-
else
|
34
|
-
# Printing to stdout can mangle up the response if we're piping the value to
|
35
|
-
# jq. For exampe, `jets call --local .. | jq`
|
36
|
-
# By redirecting stderr we can use jq.
|
37
|
-
#
|
38
|
-
$stdout = $stderr # jets call and local jets operation
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Used in ruby_server.rb
|
43
|
-
def flush_output
|
44
|
-
IO.write("/tmp/jets-output.log", $stdout.string)
|
45
|
-
# Thanks: https://stackoverflow.com/questions/28445000/how-can-i-clear-a-stringio-instance
|
46
|
-
$stdout.truncate(0)
|
47
|
-
$stdout.rewind
|
31
|
+
$stdout = $stderr # jets call and local jets operation
|
48
32
|
end
|
49
33
|
|
50
34
|
# require_bundle_gems called when environment boots up via Jets.boot. It
|
data/lib/jets/commands/deploy.rb
CHANGED
@@ -12,6 +12,7 @@ module Jets::Commands
|
|
12
12
|
puts "Deploying to Lambda #{deployment_env} environment..."
|
13
13
|
return if @options[:noop]
|
14
14
|
|
15
|
+
check_dev_mode
|
15
16
|
build_code
|
16
17
|
validate_routes!
|
17
18
|
|
@@ -24,6 +25,13 @@ module Jets::Commands
|
|
24
25
|
end
|
25
26
|
time :run
|
26
27
|
|
28
|
+
def check_dev_mode
|
29
|
+
if File.exist?("#{Jets.root}dev.mode")
|
30
|
+
puts "The dev.mode file exists. Please removed it and run bundle update before you deploy.".colorize(:red)
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
27
35
|
def build_code
|
28
36
|
Jets::Commands::Build.new(@options).build_code
|
29
37
|
end
|
data/lib/jets/core.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Works with jets/io.rb
|
2
|
+
module Kernel
|
3
|
+
@@io_buffer = []
|
4
|
+
|
5
|
+
alias_method :original_puts, :puts
|
6
|
+
def puts(message)
|
7
|
+
@@io_buffer << message
|
8
|
+
original_puts(message)
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO: implement other methods that write output:
|
12
|
+
# p, print, printf, putc, puts, sprintf?
|
13
|
+
# Also, would be nice to figure out pp method also.
|
14
|
+
|
15
|
+
def io_buffer
|
16
|
+
@@io_buffer
|
17
|
+
end
|
18
|
+
|
19
|
+
def io_flush
|
20
|
+
IO.write("/tmp/jets-output.log", @@io_buffer.join("\n"))
|
21
|
+
@@io_buffer = []
|
22
|
+
end
|
23
|
+
end
|
data/lib/jets/io.rb
ADDED
data/lib/jets/logger.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Jets
|
4
|
+
class Logger < ::Logger
|
5
|
+
# Only need to override the add method as the other calls all lead to it.
|
6
|
+
def add(severity, message = nil, progname = nil)
|
7
|
+
# Taken from Logger#add source
|
8
|
+
# https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add
|
9
|
+
if message.nil?
|
10
|
+
if block_given?
|
11
|
+
message = yield
|
12
|
+
else
|
13
|
+
message = progname
|
14
|
+
progname = @progname
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# Put the message in the Jets::IO.buffer which will get flushed to CloudWatch.
|
18
|
+
# No need to include timestamp as CloudWatch already has a timestamp.
|
19
|
+
IO.buffer << message
|
20
|
+
|
21
|
+
super # original logical
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/jets/ruby_server.rb
CHANGED
@@ -66,7 +66,7 @@ module Jets
|
|
66
66
|
prewarm_request(event) :
|
67
67
|
standard_request(event, '{}', handler)
|
68
68
|
|
69
|
-
Jets::
|
69
|
+
Jets::IO.flush # flush output and write to disk for node shim
|
70
70
|
|
71
71
|
client.puts(result)
|
72
72
|
client.close
|
@@ -76,6 +76,7 @@ module Jets
|
|
76
76
|
def prewarm_request(event)
|
77
77
|
# JSON.dump("prewarmed_at" => Time.now.to_s)
|
78
78
|
Jets.increase_prewarm_count
|
79
|
+
Jets.logger.info("Prewarm request")
|
79
80
|
%Q|{"prewarmed_at":"#{Time.now.to_s}"}| # raw json for speed
|
80
81
|
end
|
81
82
|
|
data/lib/jets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -548,6 +548,7 @@ files:
|
|
548
548
|
- lib/jets/controller/rendering.rb
|
549
549
|
- lib/jets/controller/request.rb
|
550
550
|
- lib/jets/core.rb
|
551
|
+
- lib/jets/core_ext/kernel.rb
|
551
552
|
- lib/jets/default/application.rb
|
552
553
|
- lib/jets/dotenv.rb
|
553
554
|
- lib/jets/erb.rb
|
@@ -571,6 +572,7 @@ files:
|
|
571
572
|
- lib/jets/internal/app/controllers/jets/welcome_controller.rb
|
572
573
|
- lib/jets/internal/app/controllers/jets/welcome_controller/python/index.py
|
573
574
|
- lib/jets/internal/app/jobs/jets/preheat_job.rb
|
575
|
+
- lib/jets/io.rb
|
574
576
|
- lib/jets/job.rb
|
575
577
|
- lib/jets/job/base.rb
|
576
578
|
- lib/jets/job/dsl.rb
|
@@ -582,6 +584,7 @@ files:
|
|
582
584
|
- lib/jets/lambda/function_constructor.rb
|
583
585
|
- lib/jets/lambda/functions.rb
|
584
586
|
- lib/jets/lambda/task.rb
|
587
|
+
- lib/jets/logger.rb
|
585
588
|
- lib/jets/naming.rb
|
586
589
|
- lib/jets/pascalize.rb
|
587
590
|
- lib/jets/poly_fun.rb
|