-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
executable file
·48 lines (37 loc) · 888 Bytes
/
start
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'choice'
require 'lib/pushy/app'
Choice.options do
header ''
header 'Available options:'
option :host do
short '-h'
long '--host=HOST'
desc 'The hostname or ip of the host to bind to (default 0.0.0.0)'
default '0.0.0.0'
end
option :port do
short '-p'
long '--port=PORT'
desc 'The port to listen on (default 4000)'
cast Integer
default 4000
end
end
require 'lib/pushy'
EM::run do
host = Choice.choices[:host]
port = Choice.choices[:port]
app = Pushy::App.new
begin
EM::start_server host, port, PushyServer, app
puts "Started Pushy on #{host}:#{port}"
rescue RuntimeError => e
if e.message == 'no acceptor'
$stderr.puts "Could not start Pushy. Is something else listening on port #{port}?"
end
EM::stop_event_loop
end
end