6 ms·
The one thing I wish was slicker in the Python/Django world is deployment. We just got done migrating five complete websites to new hardware. In that process
by rebootthesystem 11y ago
The one thing I wish was slicker in the Python/Django world is deployment.
We just got done migrating five complete websites to new hardware. In that process one had to be completely re-written from scratch and the other four had various levels of tweaking, adjusting and fixing.
The process was smooth as silk. No problems at all with deployment, live site testing, etc.
Oh, yes, these were all PHP sites.
I don't want to go into a Python vs. PHP discussion here. I'll simply say I am not a fan of PHP and by far prefer Python for most web (and other) work.
And still, I have to say, when it is time to deploy a Python site we have to go through a checklist to make sure every little gizmo that needs to be in place is in place. Well, now we have Ansible scripts, but that's besides the point. With PHP we just FTP from our local repository to the live server and it's up and running with almost no setup.
I also have to generalize and say that most of the Python/Django sites we've worked on are far, far more complex and involved than the typical PHP sites we see. This is where, to me at least, Python/Django shine.
Anyhow, maybe we are being lazy. Don't know. It'd be interesting to hear from others who might do a lot of Python/Django work.
- Daishiman 11y agoThe simplest way to deploy Django nowadays is uwsgi. It can do everything, including serving static files with good performance. Setting up some routes, the virtual environment, and env variables is a breeze. It's easy to test locally to see if it's breaking, and trivial to restart. uWSGI is a pretty amazing piece of tech. A small binary which can do practically everything you need out a web server, really fast, and simple to configure.
- methodover 11y agoMight I point you to Fabric? IMO, it's much, much, much easier to work with than Ansible. At my startup, we've got a nice, 100-line or so script which does all the deployment work for our Django application. (Most of that isn't even Python-specific.)
- _yy 11y agoFabric exclusively uses the Paramiko SSH library, which means that it can't use any of the newer OpenSSH ciphers and is kinda slow. Ansible can use either. In my opinion, it's easier to work with than Fabric, too.
- kayman 11y agoI have developed a deployment workflow for Python/Django with UWSGI. I've modified this flow slightly to use with web.py and flask deploments as well. I repeatedly use this for all my deployments and refer to my own notes during deployment. My notes here: http://blog.busilogic.com/deploy-python-uwsgi-app-to-digital-ocean-vps.html http://blog.busilogic.com/deploy-python-uwsgi-app-to-digital... It's not as easy as deploying a PHP app, but overall the python/django stack with uwsgi feels right with enough options built in to suit your needs.
- mtbcoder 11y ago> With PHP we just FTP from our local repository to the live server and it's up and running with almost no setup. Technically you can do that with Python as well depending on your setup. Although you may need an extra step such as "touching" your wsgi.py file. If you aren't caching your templates[1] (which you should in production though), you can upload template files and see instant changes. [1] https://docs.djangoproject.com/en/1.8/ref/templates/api/#django.template.loaders.cached.Loader https://docs.djangoproject.com/en/1.8/ref/templates/api/#dja... Also, I find deploying with mod_wsgi or uwsgi not any more difficult or time consuming than getting PHP-FPM set up and running.
- jon-wood 11y agoI sometimes hear this, and I think its a case of comparing apples to oranges. Yes, if you have a brochureware site with a few bits of database interactivity, you can just FTP a few files somewhere and have your PHP app up and running. The moment you start to introduce elements such as background queues, or more than a few developers on the team, you start to get into the realms of needing something more robust and doing config management. Facebook uses PHP. I very much doubt their deployment process is to FTP a few files to the right place.
- xmatos 11y agogit push remote Setup the post_update git hook script to checkout to the webserver path and run django admin commands to collect static files and sync the database. You can also setup a test environment to run your tests first, before updating production. Coming from a .NET background, where everything is done through the point-and-click IDE, I find it couldn't be easier and pain-free than that.
- rebootthesystem 11y agoRather than reply individually I'll just say thanks to all who made suggestions. I'll look into this and see what we can learn. We typically use nginx, gunicorn and supervisor with Ansible.