Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-static
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-static
Commits
d70f6135
Commit
d70f6135
authored
Jul 17, 2015
by
Terence Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug option for more nginx logs
parent
47e8f6de
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
6 deletions
+46
-6
nginx_config.rb
scripts/config/lib/nginx_config.rb
+1
-0
nginx.conf.erb
scripts/config/templates/nginx.conf.erb
+5
-0
index.html
spec/fixtures/debug/public_html/index.html
+1
-0
static.json
spec/fixtures/debug/static.json
+3
-0
simple_spec.rb
spec/simple_spec.rb
+21
-0
app_runner.rb
spec/support/app_runner.rb
+15
-6
No files found.
scripts/config/lib/nginx_config.rb
View file @
d70f6135
...
...
@@ -20,6 +20,7 @@ class NginxConfig
json
[
"routes"
]
=
Hash
[
json
[
"routes"
].
map
{
|
route
,
target
|
[
NginxConfigUtil
.
to_regex
(
route
),
target
]
}]
json
[
"redirects"
]
||=
{}
json
[
"error_page"
]
||=
nil
json
[
"debug"
]
||=
ENV
[
'STATIC_DEBUG'
]
json
.
each
do
|
key
,
value
|
self
.
class
.
send
(
:define_method
,
key
)
{
value
}
end
...
...
scripts/config/templates/nginx.conf.erb
View file @
d70f6135
...
...
@@ -18,7 +18,12 @@ http {
server_tokens off;
access_log logs/access.log;
<%
if
debug
%>
error_log stderr debug;
rewrite_log on;
<%
else
%>
error_log stderr;
<%
end
%>
include mime.types;
default_type application/octet-stream;
...
...
spec/fixtures/debug/public_html/index.html
0 → 100644
View file @
d70f6135
Hello World
spec/fixtures/debug/static.json
0 → 100644
View file @
d70f6135
{
"debug"
:
true
}
spec/simple_spec.rb
View file @
d70f6135
...
...
@@ -293,4 +293,25 @@ STATIC_JSON
end
end
end
describe
"debug"
do
let
(
:name
)
{
"debug"
}
context
"when debug is set"
do
it
"should display debug info"
do
_
,
io_stream
=
app
.
get
(
"/"
,
true
)
expect
(
io_stream
.
string
).
to
include
(
"[info]"
)
end
end
context
"when debug isn't set"
do
let
(
:name
)
{
"hello_world"
}
it
"should not display debug info"
do
skip
if
@debug
_
,
io_stream
=
app
.
get
(
"/"
,
true
)
expect
(
io_stream
.
string
).
not_to
include
(
"[info]"
)
end
end
end
end
spec/support/app_runner.rb
View file @
d70f6135
...
...
@@ -22,6 +22,7 @@ class AppRunner
def
initialize
(
fixture
,
env
=
nil
,
debug
=
false
)
@run
=
false
@debug
=
debug
env
.
merge!
(
"STATIC_DEBUG"
=>
true
)
if
@debug
@container
=
Docker
::
Container
.
create
(
'Image'
=>
BuildpackBuilder
::
TAG
,
'Cmd'
=>
[
"bash"
,
"-c"
,
"cp -rf /src/* /app/ && /app/bin/boot"
],
...
...
@@ -39,17 +40,20 @@ class AppRunner
)
end
def
run
def
run
(
capture_io
=
false
)
@run
=
true
retn
=
nil
latch
=
Concurrent
::
CountDownLatch
.
new
(
1
)
io_stream
=
StringIO
.
new
run_thread
=
Thread
.
new
{
latch
.
wait
(
0.5
)
yield
(
@container
)
}
container_thread
=
Thread
.
new
{
@container
.
tap
(
&
:start
).
attach
do
|
stream
,
chunk
|
puts
"
#{
stream
}
:
#{
chunk
}
"
if
@debug
io_message
=
"
#{
stream
}
:
#{
chunk
}
"
puts
io_message
if
@debug
io_stream
<<
io_message
if
capture_io
latch
.
count_down
if
chunk
.
include?
(
"Starting nginx..."
)
end
}
...
...
@@ -57,16 +61,21 @@ class AppRunner
retn
=
run_thread
.
value
@container
.
stop
container_thread
.
join
io_stream
.
close_write
@run
=
false
retn
if
capture_io
[
retn
,
io_stream
]
else
retn
end
end
def
get
(
path
,
max_retries
=
5
)
def
get
(
path
,
capture_io
=
false
,
max_retries
=
5
)
if
@run
response
=
get_retry
(
path
,
max_retries
)
get_retry
(
path
,
max_retries
)
else
run
{
get_retry
(
path
,
max_retries
)
}
run
(
capture_io
)
{
get_retry
(
path
,
max_retries
)
}
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment