Going Cloud
Tags: cloud, workflow, experiment, terminal
Published: 2018-08-06 07:08:41

---
title: Going Cloud
published: true
description: Doing all my work on a remote server
tags: #cloud #workflow #experiment #terminal
---

I few weeks back I decided to try out a new workflow for my assignments and projects. This involved doing all my work on a remote server including coding, compiling and checking output. 


## Reason

The main reason I wanted to try this out was because I hated carrying my laptop to college everyday (its almost 2.7kgs) and wanted a workflow that can be easily ported and can work from anywhere. I also had 100$ digitalocean joining credit which I thought could be put to good use.

## Setup
This was an easy part. All I needed was to create a virtual machine and install necessary language tools.
I went with the stable ubuntu 16.04 vm and installed Python, Nodejs and cloned my projects from github.
Now take care to select a vm near to your location, as this will decrease latency and improve the overall experience

## First tries : sshfs
I was reluctant to give up the comforts of my favorite editor so I thought I could mount the remote server as a folder and then open those files through text editor. This was obvioulsy going to be faster than using vnc or any other kind of remote desktop protocol.

This worked fine for small assignments but slowed down for projects with a lot of files. I was working on a react project and indexing all modules became a big task. This also meant you needed to install all basic language tools locally and remote server served as nothing more than a network drive.

During this mess of a workflow I also learnt about [direnv](https://direnv.net/), a tool to set environment variables specific to each project directory. You should check it out if you haven't already.

## A better workflow
Second logical workflow involved using exclusively just the terminal and ssh into the remote server.
Just cloning the repo and installing stuff wasn't going to cut it. Every time I needed to work I had to ssh into machine and navigate to that repo then open a file to edit it. Working on multiple files by opening multiple terminal windows was a nightmare. 

Now came TMUX, like a savior from the dark. It was just the solution I needed and more. Honestly anyone who has used tmux knows how awesome it is and I recommend it to everyone to try it out. It is used to create multiple terminals inside a single console window. Taking terminator and applying it inside a console instead of using it on a gui.

![TMUX](https://www.tecmint.com/wp-content/uploads/2016/01/Tmux-Manage-Multiple-Linux-Terminals.png)
Image from tecmint, check out their [tmux article](https://www.tecmint.com/tmux-to-access-multiple-linux-terminals-inside-a-single-console/) for deeper look.

TMUX starts a session and each session contains some windows and each window can be divided into multiple panes.  TMUX session don't need to be closed whenever you close a terminal window they can be suspended to background. 
This meant I don't even need to start a new session every time I need to work, all I need to do is create a session after I am done cloning the repo. Now whenever I ssh I could just open that session and start working on my project.
This solved a lot of problems, I didn't have to write any script to start a session and my environment was always ready whenever I wanted to start working.

## Downsides
There are obviously a lot of downsides to this approach.
1. You loose any support for gui editors and are locked with terminal editors like vim and emacs.
2. Some workflows are straight up impossible to shift to cloud like developing GUI apps or working with external devices. These will require a lot of extra setup and might not be optimized and won't be as portable.

Have you tried any interesting workflows you might want to discuss about in the comment section?