-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
in which multiple apps are provisioned at startup
- Loading branch information
Showing
2 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | 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 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | 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 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) | ||
|