         IO.puts "Websocket connection closed"
     end
   end
+
+  defp api_key do
+    System.get_env("DOCKERCLOUD_AUTH")
+  end
+
+  defp nginx_service_name do
+    System.get_env("LUCKDRAGON_NGINX_SERVICE_NAME")
+  end
 end


  def reload_nginx_container(resource_uri) do
    path = "#{resource_uri}exec/?command=nginx%20-s%20reload"
    Socket.Web.connect! @wss_address, path: path, api_key: @api_key, secure: true, custom_headers: %{Authorization: @api_key}
  end

  defp request(url) do
    case HTTPoison.get("#{@api_address}#{url}", [
      "Authorization": @api_key, 
      "Accept": "application/json"
    ]) do
      {:ok, %HTTPoison.Response{status_code: 200, body: body}} ->


  @wss_address          "ws.cloud.docker.com"
  @api_address          "https://cloud.docker.com"

  def listen_events do
    Events.start_link []
    spawn_link(Processor, :process, [])

    path = "/api/audit/v1/events"
    socket = Socket.Web.connect! @wss_address, path: path, secure: true, custom_headers: %{Authorization: api_key}

    socket
    |> receive_message
