On Github donatasm / hacking-an-nginx-module
start_new_master() {
  echo -n $"Starting new master $prog: "
  killproc -p $PIDFILE $prog -USR2
}
kill_old_master() {
    echo -n $"Killing old master $prog: "
    old_pid_file="$pid_location/running.pid.oldbin"
    killproc -p $old_pid_file $prog -QUIT
}
upgrade() {
    start_new_master
    sleep 1
    kill_old_master
}
          
				
worker_processes 16;
working_directory /usr/local/bidder-http/logs/;
http {
  error_log /usr/local/bidder-http/logs/error.log warn;
  log_not_found off;
  server {
    listen *:80;
    location /bidder/bids {
      bidder name handler=openrtb timeout=80 bidders;
    }
  }
  upstream bidders {
    bidder_req_limit;
  	server 11.12.13.14:8080 weight=4 max_fails=0 max_conns=6 req_limit=128;
  }
}
          
				
it should "return empty bid response " +
  "when request contains requestId field" in withNginxBidder { bidder =>
  val requestId = random.nextLong()
  val response = bidder.client
    .send(createBidRequest(requestId))
  response should equal (emptyBidResponse(requestId))
}
          
				
  it should "send request to the bidder" in withNginxBidder { bidder =>
    val bidRequestBody = Array[Byte](1, 2, 3, 4, 5)
    val bidRequest = createBidRequest(bidRequestBody)
    bidder.server.respondWith(EmptyBidResponse)
    val bidResponse = bidder.client.send(bidRequest)
    bidResponse should equal(EmptyBidResponse)
    bidder.server.requests should contain (bidRequest)
  }
  it should "return 413 for huge request body" in withNginxBidder { bidder =>
    val bidRequestBody = (for (i <- 1 to 10000000) yield 1.toByte).toArray
    val bidRequest = createBidRequest(bidRequestBody)
    val bidResponse = bidder.client.send(bidRequest)
    bidResponse should equal (HttpResponse(413, HttpEntity.Empty,
      List(`Content-Length`(0), `Connection`("close"))))
  }
          
				
def withNginxBidder(testCode: Bidder => Any): Unit = {
  var nginx: Nginx = null
  var bidder: Bidder = null
  implicit val system = ActorSystem("bidder-http", akkaConfig)
  try {
    nginx = Nginx()
    nginx.errors should not include "[emerg]"
    nginx.errors should not include "[error]"
    bidder = new Bidder
    nginx.spinUntilStarted(100)
    testCode(bidder)
  }
  finally {
    system.shutdown()
    system.awaitTermination()
    if (nginx != null) {
      Try(nginx.destroy())
      assert(nginx.exitCode != Signal.SIGSEGV,
        "nginx process exited with segmentation fault")
    }
  }
}
          
				
#!/bin/sh
wrk -c4096 -t16 -d1h \
  --latency --script request.lua \
  http://1.2.3.4:7070/bids
          
				
./configure --with-debug
gdb /path/to/nginx core.dump
backtrace full
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, request->connection->log, 0,
  "THIS IS DEBUG MESSAGE");