Skip to content
Browse files

in which multiple apps are provisioned at startup

  • Loading branch information...
1 parent 300273f commit 93f28d1f6e56f0e89e1041b75ce2e9665d8bc09b @ssutch ssutch committed
Showing with 69 additions and 4 deletions.
  1. +41 −0 example_conf.json
  2. +28 −4 example_tac.tac
View
41 example_conf.json
@@ -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
+ }
+ ]
+}
View
32 example_tac.tac
@@ -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 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")
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)
-server = twisted.application.internet.TCPServer(7077, site)
+server = twisted.application.internet.TCPServer(port, site)
server.setServiceParent(application)
-

0 comments on commit 93f28d1

Please sign in to comment.
Something went wrong with that request. Please try again.