about summary refs log tree commit homepage
path: root/bin/unicorn-hello-world
diff options
context:
space:
mode:
Diffstat (limited to 'bin/unicorn-hello-world')
-rwxr-xr-xbin/unicorn-hello-world26
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/unicorn-hello-world b/bin/unicorn-hello-world
new file mode 100755
index 0000000..2aba773
--- /dev/null
+++ b/bin/unicorn-hello-world
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+# Simple "Hello World" application for Unicorn
+
+# Exec ourselves with unicorn.  A shebang (e.g. "#!/usr/bin/unicorn")
+# won't work since unicorn itself is a Ruby script with a shebang, but
+# this does:
+exec('unicorn', $0) if $0 == __FILE__
+
+# Rack-compatible "Hello World" application
+class HelloWorld
+  MSG = "Hello world!\n"
+
+  def call(env)
+    [ 200,
+       { "Content-Type" => "text/plain",
+         "Content-Length" => MSG.size},
+     [ MSG ]
+    ]
+  end
+end
+
+# make sure this hash is the last statement, as this is eval-ed by unicorn
+{
+  # :listeners => %w(0.0.0.0:8080 127.0.0.1:7701 /tmp/test.sock),
+  :app => HelloWorld.new,
+}