Permalink
Browse files

Use rack to run the application

  • Loading branch information...
smgt committed Sep 1, 2012
1 parent c998bde commit 8fedd5149750ffaf8937b48fbd76aa87286d9995
Showing with 10 additions and 7 deletions.
  1. +2 −1 app.rb
  2. +6 −5 bin/timesheet.sh
  3. +2 −1 config.ru
View
3 app.rb
@@ -1,11 +1,12 @@
+$: << File.dirname(__FILE__)
require 'sinatra'
require 'sinatra/base'
require 'sinatra/respond_with'
require 'sinatra/reloader' if development?
require 'haml'
require 'sass'
require 'json'
-require './tracker'
+require 'tracker.rb'
class Timesheet < Sinatra::Base
View
@@ -1,26 +1,27 @@
#!/bin/bash
PIDFILE=$(dirname $0)/../data/ts.pid
+HOST=127.0.0.1
PORT=1337
+RACK_ENV="production"
case "$1" in
start)
echo "Start tracking"
- curl -X POST -F "cmd=start" localhost:$PORT/index.text
+ curl -X POST -F "cmd=start" $HOST:$PORT/index.json
;;
stop)
echo "Stop tracking"
- curl -X POST -F "cmd=stop" -F "comment=$2" localhost:$PORT/index.text
+ curl -X POST -F "cmd=stop" -F "comment=$2" $HOST:$PORT/index.json
;;
status)
echo "Check status"
- curl -X GET localhost:$PORT/index.text
+ curl -X GET $HOST:$PORT/index.txt
;;
startd)
echo "Starting daemon"
- ruby app.rb -p $PORT &> $(dirname $0)/../data/production.log &
- echo $! > $PIDFILE
+ rackup -D -o $HOST -p $PORT -P $PIDFILE $(dirname $0)/../config.ru #&> $(dirname $0)/../data/production.log &
;;
stopd)
echo "stopping daemon"
View
@@ -1,3 +1,4 @@
+$: << File.dirname(__FILE__)
require "sinatra"
-require "./app.rb"
+require "app.rb"
run Timesheet

0 comments on commit 8fedd51

Please sign in to comment.