I have and have had many sites that I run. They're all some form of side-project.
What they almost all have in common is two things
Many many years ago, when current interns I work with were mere babies, I started a very simple "procedure".
On the server, in the user directory where the site is deployed, I write a script called something like
upgrade_myproject.sh which is executable and does what the name of the script is: it upgrades the site.
In the server's
root home directory I write a script called
restart_myproject.sh which also does exactly what the name of the script is: it restarts the service.
On my laptop, in my
~/bin directory I create a script called
UpgradeMyproject.sh (*) which runs
upgrade_myproject.sh on the server and runs
restart_myproject.sh also on the server.
And here is, if I may say so, the cleverness of this; I use ssh to execute these scripts remotely by simply piping the commands to
ssh. For example:
#!/bin/bash echo "./upgrade_generousfriends.sh" | ssh -A email@example.com echo "./restart_generousfriends.sh" | ssh firstname.lastname@example.org
That's an example I use for Wish List Granted.
This means that all I need to do run a deployment is just type
UpgradeMyproject.sh[ENTER] and the simple little bash scripts takes care of everything else.
The reason I keep these on the server and not on my laptop is simply because that's where they naturally belong and if I'm ssh'ed in and mess around I don't have to exit out to re-run them.
Here's an example of the
upgrade_generousfriends.sh I use for Wish List Granted:
#!/bin/bash cd generousfriends source venv/bin/activate git pull origin master find . | grep '\.pyc$' | xargs rm -f pip install -r requirements/prod.txt ./manage.py syncdb --noinput ./manage.py migrate webapp.main ./manage.py collectstatic --noinput ./manage.py compress --force echo "Restart must be done by root"
I hope that, by blogging about this, that someone else sees that it doesn't really have to be that complicated. It's not rocket science and most complex tools are only really needed when you have a significant bigger scale in terms of people- and skill-complexity.
Keep it simple.
(*) The reason for the capitalization of my scripts is also an old habit. I use that habit to differentiate my scripts for stuff I install from any third parties.