Visual safety development

by on under programming
2 minute read

Visual warnings when developing on multiple environments

It is common for a developer or sysadmin to have access to multiple environments or servers such as production (live) (server-1), test (staging) and perhaps localhost (server-2).

The problem with this is that it’s easy to forget which environment you’re using.

One solution would be to have a mental pre-check of “am I on server X… yes I am” before running any commands that perform changes (writes/updates). However this is bound to fail you one day.

Another solution is making a visual clue appear which makes it clear consciously or subconsciously which server you’re using.

SQL Server Management Studio (SSMS)

Server 1 connection pane. In this example server-1 is our live production environment.

server-1

Server 1 connection options.

server-1-settings

Server 2 connection pane. In this example server-2 is our localhost environment.

server-2

Server 2 connection options.

server-2-settings

Here is the server list on the left. Top one is localhost (server-2) and bottom is live production (server-1).

server-list

Running a SQL query against server-1 shows us the nice warning at the bottom.

server-1-query-pane

Running a SQL query against server-2 shows us we’re safe.

server-2-query-pane

Insomnia REST

I use Insomnia which is like Postman for my API testing. I have various environment variables such as URIs which get swapped out based on environment.

Live environment shows red as a warning.

insomnia-live

Staging environment shows orange as a warning.

insomnia-staging

Localhost environment shows green as we’re safe.

insomnia-local

Linux SSH

From my .bashrc I deploy on remote servers and local machines.

if [ "$color_prompt" == yes ]; then
	if [ ! "$SSH_CLIENT" == "" ]; then
		# If this is a ssh session then change our PS1 colour to let them know it's remote.
		PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
	else
		# If this isn't a ssh connection then use our normal colour PS1.
		PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
	fi
else
	PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

Green for local.

local-ssh

Yellow for remote.

remote-ssh

API, SQL,
comments powered by Disqus