Friday 3 June 2011

Reduce The Risk of Human Error on Live Servers

This is another quick and easy tip, this time help to reduce human error when working between live, development and staging environments.

In short the tip is to visually distinguish between live/staging/dev environments; the idea being that you don't accidentally run something on the live environment instead of staging or testing. Assuming you're connecting via SSH, you should be able to configure your console program to use a background image and you should be able to customise your command prompt.



Console Background Image
If you have a lot of servers you might like to have the server name as background, otherwise maybe just to distinguish between live, staging and testing is enough. Here LIVE, STAGING and TESTING on black and white for your use.  You can have these on Creative Commons,  but hit me with a link please. :)






LIVE - white console background LIVE - black console background


STAGING - white console background STAGING - black console background


TESTING - white console background TESTING - black console background



When I get a chance I'll release the very simple Python script that I use to generate these.

Custom Console Prompt
This can a be quite a powerful and helpful tool. Here's a helpful link the the Bash Prompt HowTo  and a jump to the colours page. You can look up the details yourself, to achieve your desired effect.
This is my prompt:
PS1="\[\e[30;1m\]\u@\h:\[\e[34;1m\]\w\n\`if [ \$? = 0 ]; then echo \[\e[30m\]! \!\[\e[30m\]\$; else echo \[\e[31m\]! \!\[\e[30\;0m\]\$; fi\` \[\e[0m\\]"

Which looks like this:


You can see, it has my username, server name, current directory path, then a newline and my command history number, which is in my default text colour if the command I just execute was successful and red if it failed. Notice also a nice background picture ;)

Hope this may help make your working life a little bit easier.