{"id":19739758,"url":"https://github.com/philipsahli/django-golive","last_synced_at":"2025-07-06T13:32:44.106Z","repository":{"id":7985647,"uuid":"9390487","full_name":"philipsahli/django-golive","owner":"philipsahli","description":"django-golive is focusing on the tasks executed on your hosts to deploy and operate a Django-powered site. ","archived":false,"fork":false,"pushed_at":"2014-03-17T10:42:10.000Z","size":542,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T05:59:44.540Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://sahli.net/django-golive","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philipsahli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-12T09:05:02.000Z","updated_at":"2014-03-17T10:42:10.000Z","dependencies_parsed_at":"2022-07-22T05:32:33.635Z","dependency_job_id":null,"html_url":"https://github.com/philipsahli/django-golive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/philipsahli/django-golive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipsahli%2Fdjango-golive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipsahli%2Fdjango-golive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipsahli%2Fdjango-golive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipsahli%2Fdjango-golive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philipsahli","download_url":"https://codeload.github.com/philipsahli/django-golive/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipsahli%2Fdjango-golive/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263908354,"owners_count":23528433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T01:18:17.726Z","updated_at":"2025-07-06T13:32:44.034Z","avatar_url":"https://github.com/philipsahli.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-golive\n=============\n\n[![Build Status](https://travis-ci.org/fatrix/django-golive.png?branch=master)](https://travis-ci.org/fatrix/django-golive)\n\n\u003e ... is not yet production ready. If you are interested in any updates on it:\n\n\u003e - follow [me] on Twitter\n\u003e - join the [Mailinglist]\n\u003e - visit [http://sahli.net/django-golive](sahli-golive)\n\ndjango-golive is focusing on the tasks executed on servers to deploy and operate a Django-powered site.\nFor the most common configurations you have to create a virtualenv, setup a database, install python-modules from pip\nand configure a webserver in front of a WSGI-process.\n\nAll these steps does django-golive for you. All you have to do is to prepare your project, which takes less\nthan 5 minutes. Then you are ready to enjoy django-golive and repeat yourself even less!\n\nWhat brings django-golive?\n--------------------------\n\n- Django-admin commands to deploy your project to a remote server(s)\n- Preconfigured stacks (configuration templates ready to use)\n- Multiple environments handling (i.e. testing, production)\n\n\nGetting started\n---------------\n\nInstall django-golive\n\n    pip install django-golive\n\nAdd django-golive to settings.INSTALLED_APPS\n\n    vi settings.py\n\nCreate initial configuration file golive.yml\n\n    python manage.py create_config\n\nCustomize golive.yml\n\n    vi golive.yml\n\nDeploy the basics\n\n\u003e Install a [Debian][debian] server on your own platform or choose a hosting provider (e.g. [IntoVPS][intovps]).\n\u003e Don't forget to create the `INITIAL_USER` on the server with public key authentication.\n\n    python manage.py init ENV                         # change ENV to your ENV_ID\n\nSet your secrets\n\n    python manage.py set_var ENV MYVAR 'VALUE'        # Set variables which you can use in your\n                                                              #    settings file, e.g.:\n                                                              #\n                                                              #    import os\n                                                              #    os.environ['GOLIVE_MYVAR']\n\nIn your settings module you can access the secrets like in the following example:\n\n    from golive.utils import get_var\n    DATABASES['default']['PASSWORD'] = get_var('DB_PASSWORD')\n\nCreate settings file for environment\n\n\u003e This step is needed only if different settings applies on the remote environment. e.g. `DEBUG = False`\n\n    echo \"from settings import *\" \u003e settings_ENV.py   # change ENV to your ENV_ID\n    echo \"DEBUG = False\" \u003e\u003e settings_ENV.py           # change ENV to your ENV_ID\n\nDeploy the rest\n\n    python manage.py deploy ENV                       # change ENV to your ENV_ID\n\nVisit your page with curl:\n\n    curl http://SERVERNAME:80                                 # you configured SERVERNAME in golive.yml\n\nConfiguration\n--------\n\nYou can create with the following command a starting configuration file `golive.yml` in the root of your Django-project:\n\n    python manage.py create_config\n\nThe configuration file contains the desired stack, default and configurations per environment:\n\n    CONFIG:\n      PLATFORM: DEDICATED\n      STACK: CLASSIC\n\n    ENVIRONMENTS:\n      DEFAULTS:\n        INIT_USER: root                 # For the user creation step\n        PROJECT_NAME: exampleproject\n        USER: exampleuser               # If not specified: {{PROJECT_NAME}}_{{ENV}}\n        PUBKEY: $HOME/.ssh/id_dsa.pub   # Is copied to /home/$USER/.ssh/authorized_keys2\n\n      TESTING:\n          USER: exampleuser             # If not specified: {{PROJECT_NAME}}_{{ENV}}\n          SERVERNAME: golivetesting     # Used as virtualhost name in webserver configuration\n          ROLES:                        # All of the hosts must be resolvable (DNS, hostfile)\n             APP_HOST:\n               - testserver\n             DB_HOST:\n               - testserver             # At the moment only one `DB_HOST` is allowed\n             WEB_HOST:\n               - testserver             # At the moment only one `WEB_HOST` is allowed\n\n\nDeployment\n----------\n### Initialization\n\n    python manage.py init ENV       # ENV can be e.g. testing, integration, production\n    python manage.py deploy ENV     # ENV can be e.g. testing, integration, production\n\n### Update the project\n    python manage.py update ENV                         # Tasks in all roles\n\n    python manage.py update ENV \\\n               --role APP_HOST                          # Tasks in specified role\n\n    python manage.py update ENV \\\n               --task golive.layers.app.DjangoSetup     # Specified task only\n\n    python manage.py update ENV \\\n               --host testserver2                       # Tasks on target host\n\nWith the option `--fast` time intensiv tasks (for deploy and update) are not executed. The option is usefull if you only update your code and static files should not be collected and not any required python module from `requirements.txt` should not be installed/upgraded.\n\n    python manage.py update ENV --fast\n\n### Check\n    python manage.py status ENV\n\n\n### Logs\n\nExecutes a `tail -f` on all logfiles located in the directory `log` on the targets.\n\n    python manage.py logs ENV\n\n\nTarget Platforms\n----------------\n\nAt the moment only deployments to a set of installed [Debian] hosts is supported (`PLATFORM: DEDICATED`).\n\nRecovery\n--------------\n\n### Backup\n\nCreates a backup of your database and downloads a gzipped tar file to your current working directory.\n\n    python manage.py backup ENV\n\n### Restore\n\nLet you choose a previously taken backup of an environment.\n\n    python manage.py restore ENV\n\n### Restore from a different environment\n\nThis feature is useful to restore your production database into the integration environment.\n\n    python manage.py restore ENV --source_env=ENV\n\nAfter restoring the database django-golive executes sql commands specified in a list specified in your settings\nas `GOLIVE_CLEANUP_RESTORE`.\n\nFor example for a mezzanine project:\n\n    GOLIVE_CLEANUP_RESTORE = [\n        'SELECT * FROM conf_setting;',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'GOOGLE_ANALYTICS_ID\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'BITLY_ACCESS_TOKEN\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'COMMENTS_DISQUS_API_PUBLIC_KEY\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'COMMENTS_DISQUS_API_SECRET_KEY\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'COMMENTS_DISQUS_SHORTNAME\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'COMMENTS_DISQUS_SHORTNAME\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'TWITTER_CONSUMER_SECRET\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'TWITTER_CONSUMER_KEY\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'TWITTER_ACCESS_TOKEN_KEY\\'',\n        'UPDATE conf_setting SET value=\\'\\' WHERE name=\\'TWITTER_ACCESS_TOKEN_SECRET\\'',\n        'UPDATE blog_blogpost SET short_url=NULL;',\n    ]\n\n\n\nBuilt-In Components\n----------\n### golive.layers.base.BaseSetup\n* OS Packages\n\n    Installs basic required and handy packages like:\n\n    `rsync, git, gcc, python-dev, postgresql-client, htop, curl, lsof, sysstat`\n\n* Host file\n\n    Adds entries for every host in environment to the file `/etc/hosts`.\n\n* Security\n\n    Sets `PasswordAuthentication` for sshd to no.\n\n* IPTables\n\n    Accept by default only connection to port tcp/22 from all hosts in the internet. All other services are denied.\n    Per service (for example public or communication within application (i.e. to database, caching service) rules are generated in the specific task.\n\n***\n\n### golive.layers.base.UserSetup\n\n* User creation\n\n    Creates the user with the name `USER` specified in `golive.yml` of if not specified as `PROJECT_NAME`_`ENV`.\n    For the first login an existant user `INIT_USER` with key-authentication is required to be able to perform these steps.\n\n* SSH Pubkey\n\n    Copies a pubkey `PUBKEY` to the `authorized_keys2` file on the servers to be able to login with key-authentication.\n\n***\n\n### golive.layers.base.CrontabSetup\n* Configure crontab per role\n\n    You can create a crontab `templates/golive/cron/ROLE.crontab` in your template folder.\n    It must extend the base template in golive and define a block `crontab` in it.\n\n    Example `db_host.crontab`:\n\n        {% extends \"golive/cron/base_db_host.crontab\" %}\n        {% block crontab %}\n        0 3 * * * {{ USER }} script.sh \u003e\u003e {{ LOGDIR }}/script.log\n        {% endblock %}\n\n    Golive creates the file in `/etc/cron.d`.\n\n***\n\n### golive.layers.web.NginxSetup\n* Configure Frontend-Webserver\n\n    Installs the package nginx and then creates out of `templates/golive/nginx.conf` a configuration file.\n    The file is uploaded to the directory `/etc/nginx/sites-enabled/app.conf`.\n\n* IPTables\n\n    Accept connections to port tcp/80 from the internet.\n\n\u003c!-- TODO: ### golive.layers.cache.RedisSetup\n- Cachehost (Redis Key/Value-Store for Caching)\n--\u003e\n\n***\n\n### golive.layers.app.PythonSetup\n* Virtualenv Environment\n\n    Creates a virtualenv in `$HOME/.virtualenvs` with the name of the project (`PROJECT_NAME`).\n\n\n\n***\n\n### golive.layers.db.PostgresSetup\n* Postgresql installation\n\n    Installs the packages `postgresql`.\n\n* Configure Postgresql\n\n    - Allow access from every host in the role `WEB_HOST`.\n    - Listen on all network interfaces (`0.0.0.0`).\n\n* IPTables\n\n    Accept connections from all hosts within environment to port tcp/5432.\n\n***\n\n### golive.layers.app.DjangoSetup\n* Directories\n\n    Creates directories: `$HOME/code, $HOME/log, $HOME/static`\n\n* Start/stop process configuration\n\n    Configures a process for supervisor. Therefor `templates/golive/supervisor_django.conf`\n    is uploaded to `/etc/supervisor/conf.d/app.conf`.\n\n    Supervisord has some limitiations in handling the process execution and the resulting environment.\n    To access the environment variables set with the command `set_var` supervisor is\n    executing a bash script `supervisor_django.run`, which exports all variables\n    from `$HOME/.golive.rc`.\n\n* Send Djangoproject\n\n    At this stept your project root is sent to the servers `$HOME/code` directory.\n\n* Install python packages with pip\n\n    Installation of the required python packages listed in `requirements.txt` in your project root.\n\n* Prepare Database\n\n    - Create user (role) `USER` on `DB_HOST`.\n    - Create database `PROJECT_NAME`_`ENV` on `DB_HOST` with owner `USER`.\n\n* Synchronize Databaseschema\n\n    Executes `syncdb` django command. If south is installed, additionally `migratedb`.\n\n* Collect staticfiles\n\n    Collects the staticfiles with the standard django-admin command to `$HOME/static/`.\n    If you have more than one host as role `APP_HOST`, then like in any other deployment procedure\n    use [django-storages] to collect your static and upload files to [Amazon S3].\n\n* Start django process\n\n    The process for django is started with `supervisorctl`:\n\n        sudo supervisorctl start app\n\n* IPTables\n\n    All connections to the tcp port are denied unless their initiated by any server in the `WEB_HOST` role.\n\n***\n\n### golive.layers.app.RabbitMqSetup\n\nTODO\n\n***\n\n### golive.layers.app.WorkerSetup\n\n* Before installation\n\n    Set the environment variable `BROKER_URL`, i.e.:\n\n        python manage.py set_var ENV BROKER_URL amqp://USERNAME:PASSWORD@HOST:5672/\n\n* Setting\n\n    Add following to your `settings.py`:\n\n        BROKER_URL = os.environ['GOLIVE_BROKER_URL']\n\n\nBuilt-In Stacks\n-------------\n\n### Classic\n\nThe very basic Django-Stack installed on your self-hosted platform ([Ubuntu] or [Debian], [Redhat] or [CentOS]):\n\n- Role `WEB_HOST` (Frontend Webserver)\n\n   - golive.layers.web.NginxSetup\n\n- One or many `APP_HOST`'s (Python-Procs for Django with builtin's server)\n\n   - golive.layers.web.NginxSetup\n\n- One `DB_HOST` (database server with Postgresql)\n\n**See Stack-File [here][example-stackfile]**\n\n### ClassicGunicorned\n\nThis Stack is inherited from `Classic`, but uses [Gunicorn] to run the project behind Nginx.\nThe Components list difference:\n\n- `APP_HOST` (Python-Procs for Django with Gunicorn)\n   - golive.layers.app.DjangoSetupGunicorn\n\n- `WEB_HOST` (Proxing to Gunicorn)\n   - golive.layers.web.NginxProxySetup\n\n\n### Gunicelery\n\nIf you need asynchronous work done with celery, this stack is the right one for you.\nIn addition to `Classicgunicorned` it needs to more roles:\n\n- Role `QUEUE_HOST` (Rabbitmq server)\n\n  - golive.layers.queue.RabbitMqSetup\n\n- Role `WORKER_HOST` (Doing the asynchronous work)\n\n  - golive.layers.app.WorkerSetup\n  - golive.layers.app.WorkerCamSetup\n\nAdd-ons\n-------------\n\n### New Relic Python Agent / New Relic Server Agent\n\nAdd following to the `CONFIG` section:\n\n     CONFIG:\n         ADDONS:\n              - NEW_RELIC_PYTHON\n              - NEW_RELIC_SERVERAGENT\n\nSet the variable `NEWRELIC_LICENSE_KEY`. Execute the commands init and deploy. Your app and server now report metrics to [New Relic][newrelic].\n\n### PgBouncer\n\nSee description on PostgreSQL Wiki: [PgBouncer][pgbouncer]\n\nAdd following to the `CONFIG` section:\n\n     CONFIG:\n         ADDONS:\n              - PGBOUNCER_ADDON\n\n- Configure pgbouncer with listening port 6432 \n- START=1 in defaults (Debian only).\n- Add username/password to userlist.txt\n- Configure database in pgbouncer.ini\n\n\nFor Developers\n--------------\n### Contribute\n\n   Forks and pull requests are welcome!\n\n### Tasks\n\n   To document\n\n### Stacks\n\n   To document\n\n### Addons\n\n   To document\n\nFeatures in the future\n----------------------\n- New stacks\n  - Django and Websockets\n  - Django and Celery\n- Testing\n  - Test on Debian 7\n- Deploy to dedicated Redhat servers\n- Deploy to IaaS platforms\n  - Amazon EC2\n  - Openstack\n- Deploy to PaaS platforms\n  - Dotcloud\n  - Openshift\n\n[example-stackfile]: golive/stacks/ \"Example Stackfile\"\n\n[ubuntu]: http://ubuntu.com \"Ubuntu\"\n[debian]: http://debian.org \"Debian\"\n[redhat]: http://redhat.org \"Redhat\"\n[centos]: http://debian.org \"Centos\"\n[intovps]: http://www.intovps.com/plans.html \"IntoVPS\"\n[nginxsetup]: http://www.bla.com\n[newrelic]: http://www.newrelic.com \"New Relic\"\n[me]: https://twitter.com/philipsahli\n[Mailinglist]: https://groups.google.com/forum/?fromgroups#!forum/django-golive\n[django-storages]: https://pypi.python.org/pypi/django-storages\n[Amazon S3]: http://aws.amazon.com/s3/\n[Gunicorn]: http://gunicorn.org/#docs\n[sahli-golive]: http://sahli.net/django-golive\n[pgbouncer]: https://wiki.postgresql.org/wiki/PgBouncer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipsahli%2Fdjango-golive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilipsahli%2Fdjango-golive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipsahli%2Fdjango-golive/lists"}