Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Operations

Jonathan Payne edited this page Jun 4, 2015 · 24 revisions

Quick daily operation commands here, or read further down for details:

VPSs and Domains

OCL has 3 server environments setup: production, staging, and dev. Each environment has a web application and an API subdomain that can be accessed at either of the parent domains openconceptlab.com and openconceptlab.org.

Environment Web Application URL API URL
production www.openconceptlab.com
www.openconceptlab.org
api.openconceptlab.com
api.openconceptlab.org
staging staging.openconceptlab.com
staging.openconceptlab.org
api.staging.openconceptlab.com
api.staging.openconceptlab.org
dev dev.openconceptlab.com
dev.openconceptlab.org
api.dev.openconceptlab.com
api.dev.openconceptlab.org

Operating Environment

The OCL operating environemnt is as follow:

  • All outside requests are handled by nginx; nginx uses named virtualhost to distinguish types of request
  • Both API and WEB django applications run internally on specific ports responding only to localhost request
  • Both applications use gunicorn and wsgi
  • Supervisor is used to control the django applications
  • Both applications run under the deploy user account

Normal Code Release Process

OCL has 3 operating environments:

  • production
  • staging
  • dev

OCL has two release scripts, one for the Web Application and one for the API:

  • release_web_app
  • release_api_app For a normal software release, navigate to the root of the ocl_web repo where the fabfiles live to do the release.
workon ocl_web
fab [:env] [:release_script]

For example:

workon ocl_web
fab dev release_web_app
fab dev release_api_app

The fab file in the oclapi repo still works as well for the api app:

workon oclapi
cd oclapi/src/django-nonrel/ocl
fab dev deploy

Normal Restart using fabric

fab dev/staging/production restart_api
fab dev/staging/production restart_web

Normal rebuild index using fabric

fab dev/staging/production rebuild_index

Starting/Stopping

Django applications

  • to start and stop the django applications, simply use the supervisor control commands using the deployment user account:
supervisorctl stop
supervisorctl start

# or

supervisorctl restart

Note that supervisorctl also has an interactive mode. Just enter supervisorctl to try.

Normally, you can just use the fabric commands to start/stop the servers remotely.

Supervisor

The supervisor daemon starts via system startup normally. To start/stop/restart it manually (as root):

/etc/init.d/supervisord start
/etc/init.d/supervisord stop
/etc/init.d/supervisord restart

nginx

The nginx light weight web server starts via system startup normally. To start/stop/restart it manually (as root):

/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx restart

Log files

All the log files are currently written to the /var/log/ocl directory. See:

  • /var/log/ocl/web_app.log for web application normal logging (via django logger)
  • /var/log/ocl/web_debug.log for web application debug logging of API calls to api server
  • /var/log/ocl/ocl_api.log for API application normal logging (via django logger)
  • /var/log/ocl/api_supervisor.log for supervisor output for the API gunicorn, sys err, outs basically
  • /var/log/ocl/web_supervisor.log for supervisor output for the WEB gunicorn, sys err, outs basically
  • /var/log/ocl/ocl_api_batch.log for import process outputs

Configuration Files

See:

  • /etc/nginx/conf.d/*.conf
  • /etc/supervisor/conf.d/*.conf

Environment Variable/Configurations

Settings for the django applications are set in the appropriate supervisor conf files: Location of directory and environment variables.

Clone this wiki locally