Sha256: b4a5e8d4e5eae1bb068fe35c188aabad19ccb0a5ea2090e0859973651c8b44b1
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'getoptlong' require 'rubygems' require 'daemons' require 'apnserver' $logger = Logger.new(STDOUT) def usage puts "Usage: apnserverd [switches] --pem <path>" puts " --bind-address [0.0.0.0] bind address of proxy" puts " --proxy-port [22195] port proxy listens on" puts " --server <gateway.push.apple.com> the apn server to send messages to" puts " --port <2195> the port of the apn server" puts " --help this message" end def daemonize Daemonize.daemonize('apnserverd', 'apnserverd') @pid_file = '/var/run/apnserverd.pid' open(@pid_file,"w") {|f| f.write(Process.pid) } # copied from mongrel open(@pid_file,"w") do |f| f.write(Process.pid) File.chmod(0644, @pid_file) end end opts = GetoptLong.new( ["--bind-address", "-b", GetoptLong::REQUIRED_ARGUMENT], ["--proxy-port", "-P", GetoptLong::REQUIRED_ARGUMENT], ["--server", "-s", GetoptLong::REQUIRED_ARGUMENT], ["--port", "-p", GetoptLong::REQUIRED_ARGUMENT], ["--pem", "-c", GetoptLong::REQUIRED_ARGUMENT], ["--help", "-h", GetoptLong::NO_ARGUMENT], ["--daemon", "-d", GetoptLong::NO_ARGUMENT] ) bind_address = '0.0.0.0' proxy_port = 22195 host = 'gateway.push.apple.com' port = 2195 pem = nil daemon = false opts.each do |opt, arg| case opt when '--help' usage when '--bind-address' bind_address = arg when '--proxy-port' proxy_port = arg.to_i when '--server' host = arg when '--port' port = arg.to_i when '--pem' pem = arg when '--daemon' daemon = true $logger = Logger.new('/var/log/apnserverd.log', 'weekly') end end if pem.nil? usage exit 1 else daemonize if daemon server = ApnServer::Server.new(pem, bind_address, proxy_port) server.client.host = host server.client.port = port server.start! end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bpoweski-apnserver-0.0.14 | bin/apnserverd |