File tree 4 files changed +65
-5
lines changed
4 files changed +65
-5
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ https://github.com/rcaught/heroku-buildpack-cmake
2
2
https://github.com/alexcrichton/heroku-buildpack-zlib-pkgconfig
3
3
https://github.com/alexcrichton/heroku-buildpack-rust
4
4
https://github.com/tonycoco/heroku-buildpack-ember-cli.git
5
-
5
+ https://github.com/ryandotsmith/nginx-buildpack.git
Original file line number Diff line number Diff line change 1
- web : ./target/release/cargo-registry
1
+ web : bin/start-nginx ./target/release/cargo-registry
Original file line number Diff line number Diff line change
1
+ daemon off;
2
+ #Heroku dynos have at least 4 cores.
3
+ worker_processes <%= ENV['NGINX_WORKERS'] || 4 %> ;
4
+
5
+ events {
6
+ use epoll;
7
+ accept_mutex on;
8
+ worker_connections 1024;
9
+ }
10
+
11
+ http {
12
+ gzip on;
13
+ gzip_comp_level 2;
14
+ gzip_proxied any;
15
+ gzip_min_length 512;
16
+ gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml image/svg+xml;
17
+
18
+ server_tokens off;
19
+
20
+ log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
21
+ access_log logs/nginx/access.log l2met;
22
+ error_log logs/nginx/error.log;
23
+
24
+ include mime.types;
25
+ default_type application/octet-stream;
26
+ sendfile on;
27
+
28
+ #Must read the body in 5 seconds.
29
+ client_body_timeout 5;
30
+
31
+ upstream app_server {
32
+ server localhost:8888 fail_timeout=0;
33
+ }
34
+
35
+ server {
36
+ listen <%= ENV["PORT"] %> ;
37
+ server_name _;
38
+ keepalive_timeout 5;
39
+
40
+ location ~ ^/assets/ {
41
+ add_header Cache-Control public;
42
+ root dist;
43
+ expires max;
44
+ }
45
+ location / {
46
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
47
+ proxy_set_header Host $http_host;
48
+ proxy_redirect off;
49
+ proxy_pass http://app_server;
50
+ }
51
+ }
52
+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ extern crate git2;
6
6
7
7
use std:: os;
8
8
use std:: sync:: Arc ;
9
- use std:: io:: { mod, fs} ;
9
+ use std:: io:: { mod, fs, File } ;
10
10
use civet:: Server ;
11
11
12
12
fn main ( ) {
@@ -51,10 +51,18 @@ fn main() {
51
51
}
52
52
let app = cargo_registry:: middleware ( Arc :: new ( app) ) ;
53
53
54
- let port = os:: getenv ( "PORT" ) . and_then ( |s| from_str ( s. as_slice ( ) ) )
55
- . unwrap_or ( 8888 ) ;
54
+ let heroku = os:: getenv ( "HEROKU" ) . is_some ( ) ;
55
+ let port = if heroku {
56
+ 8888
57
+ } else {
58
+ os:: getenv ( "PORT" ) . and_then ( |s| from_str ( s. as_slice ( ) ) )
59
+ . unwrap_or ( 8888 )
60
+ } ;
56
61
let _a = Server :: start ( civet:: Config { port : port, threads : 8 } , app) ;
57
62
println ! ( "listening on port {}" , port) ;
63
+ if heroku {
64
+ File :: create ( & Path :: new ( "/tmp/app-initialized" ) ) . unwrap ( ) ;
65
+ }
58
66
wait_for_sigint ( ) ;
59
67
}
60
68
You can’t perform that action at this time.
0 commit comments