summaryrefslogtreecommitdiff
path: root/script/agi_server
blob: 0a0fd76280de545e4e943ca61f663ddc00b37bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/env ruby

APP_PATH = File.expand_path('../../config/application',  __FILE__)
require File.expand_path('../../config/boot',  __FILE__)
require APP_PATH

begin
	Rails.application.require_environment!
rescue ActiveRecord::AdapterNotSpecified => e
	$stderr.puts "No such Rails environment: \"#{Rails.env}\"."
	exit 1
end

begin
	require 'agi_server'
	server_instance = AGIServer::server()
 
rescue SignalException => e
  case e.signo
  when 1
    $stderr.puts "Signal 1 caught, exiting"
  when 2
    $stderr.puts "Interrupt signal caught, exiting"
  when 15
    $stderr.puts "Exit signal caught, exiting"
  else      
    $stderr.print "#{e.class.to_s}"
    $stderr.print " (Signal #{e.signo.to_s})" if e.respond_to?(:signo) && e.signo
  end
  $stderr.puts ""
  exit (e.signo + 128)
end

exit 0