Author: | Gary Bishop |
---|---|
Author: | Peter Parente |
Description: | Configures UNC Open Web Server components as upstream services or static libraries proxied and aliased by nginx. Uses supervisord to manage running processes. |
Install at least these versions and all their prerequisites on your server.
- Python 2.6
- mongodb 1.6.3
- nginx 0.7.64
- supervisord 3.0
- Tornado 1.0
- pycurl (for Tornado)
- simplejson 2.1.1 (for Tornado, optional)
- pymongo 1.9 (for Torongo)
- iterpipes 0.4 (for JSonic)
- espeak 1.40.02 (for Jsonic)
- lame 3.98.2 (for JSonic)
- oggenc 1.2.0 (for JSonic)
- jsonschema 0.2a (for Torongo)
- Install MongoDB from its homepage
- Install Tornado from its homepage
- Install jsonschema from its homepage (http://code.google.com/p/jsonschema/)
- apt-get install supervisor nginx python-setuptools python2.6-dev python-pycurl vorbis-tools lame espeak
- easy_install pymongo iterpipes
Here's a quick tutorial that walks you through setting up two independent servers accessible via two different domains both on port 80. The resulting servers will both have independent instances of Mongo, Torongo, and JSonic running on the server as well as static web accessible folders for JavaScript libraries and a sample catalog application.
- Open servers/dev.conf in an editor.
- Set the "server_name" value in the [nginx] section to the hostname youwant to use for this server instance.
- Open servers/prod.conf in an editor.
- Set the "server_name" for the hostname to use for this second server instance.
- Run "sudo ./uow init dev" to generate the on-disk resources for the "dev" server.
- Run "sudo ./uow init prod" to generate the on-disk resources for the "prod" server.
- Run "sudo supervisord" to start all configured programs for the servers.
- Visit http://<first host>/catalog and http://<second host>/catalog in your web browser.
- View the service status and confirm the examples work.
- Run "./uow restart dev" to restart the services configured in "dev".
- Do the same for "prod" to restart the services for that configuration.
- Run "./uow disable dev" to disable the services configured in "dev".
- Run "./uow enable dev" to enable the services configured in "dev".
- Do the same for "prod" to enable or disable the services for that configuration.
- Run "sudo ./uow update dev" to reinitialize the on-disk resources for the "dev" server.
- The current "servers/dev" folder is moved to the "backups/dev" folder and timestamped.
- The server is disabled using "uow disable dev".
- The "servers/dev" folder is reinitialized using "uow init dev".
- Any folders marked for backup in the "dev.conf" are restored by copying them into "servers/dev".
- The server is enabled again using "uow enable dev".
- Do the same for "prod" server if desired.
- Run "sudo ./uow remove dev" to disable and destroy the on-disk resources for the "dev" server.
- The current "servers/dev" folder is moved to the "backups/dev" folder and timestamped.
- The server is disabled using "uow disable dev".
- The "servers/dev" folder is removed.
- Do the same for "prod" to delete it as well.
Folders backed up in "backups/" are never automatically removed. You can force their removal by running "sudo ./uow cleanup".
Some things you can do:
- Create a copy of "dev.conf" or "prod.conf" and name it something new to configure a new server instance. Adjust the section names, path names, server name and and port ranges to avoid conflicting with other running servers.
- Adjust the "numprocs" and "first_port" in a [program:*] section to create more upstream service instances. Run "uow update <servername>" to generate the new nginx config file. Use "supervisorctl reread" to reconfigure the daemon process and "supervisorctl add <name>" to start the new instances.
- Run "supervisorctl" to manually manage the running services. Type "?" or "help" to get help in the interactive console. Alternatively, visit http://localhost:9001 to use the web admin UI.