Skip to content

Commit

Permalink
in which multiple apps are provisioned at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ssutch committed Feb 15, 2012
1 parent 300273f commit 93f28d1
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
41 changes: 41 additions & 0 deletions example_conf.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"port": 7077,
"autoprovision": [
{
"app_id": "sandbox:com.ficture.ficturebeta",
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta.pem",
"environment": "sandbox",
"timeout": 15
},
{
"app_id": "production:com.ficture.ficturebeta",
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta.pem",
"environment": "production",
"timeout": 15
},
{
"app_id": "sandbox:com.ficture.ficturebeta2",
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta2.pem",
"environment": "sandbox",
"timeout": 15
},
{
"app_id": "production:com.ficture.ficturebeta2",
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta2.pem",
"environment": "production",
"timeout": 15
},
{
"app_id": "sandbox:com.ficture.ficturebeta3",
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta3.pem",
"environment": "sandbox",
"timeout": 15
},
{
"app_id": "production:com.ficture.ficturebeta3",
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta3.pem",
"environment": "production",
"timeout": 15
}
]
}
32 changes: 28 additions & 4 deletions example_tac.tac
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,36 @@
# CONFIG FILE LOCATION
# relative to this file or absolute path

config_file = 'example_conf.json'

# you don't need to change anything below this line really

import twisted.application, twisted.web, twisted.application.internet import twisted.application, twisted.web, twisted.application.internet
import pyapns.server import pyapns.server, pyapns._json
import os

with open(os.path.abspath(config_file)) as f:
config = pyapns._json.loads(f.read())


application = twisted.application.service.Application("pyapns application") application = twisted.application.service.Application("pyapns application")


resource = twisted.web.resource.Resource() resource = twisted.web.resource.Resource()
resource.putChild('', pyapns.server.APNSServer()) service = pyapns.server.APNSServer()

# get automatic provisioning
if 'autoprovision' in config:
for app in config['autoprovision']:
service.xmlrpc_provision(app['app_id'], app['cert'], app['environment'],
app['timeout'])

# get port from config or 7077
if 'port' in config:
port = config['port']
else:
port = 7077

resource.putChild('', service)
site = twisted.web.server.Site(resource) site = twisted.web.server.Site(resource)


server = twisted.application.internet.TCPServer(7077, site) server = twisted.application.internet.TCPServer(port, site)
server.setServiceParent(application) server.setServiceParent(application)

0 comments on commit 93f28d1

Please sign in to comment.