I have to do WHAT to run this code? – No one expects perfection



I have to do WHAT to run this code? – No one expects perfection

0 0


2015-JSConf

Slides for our presentation at JSConf 2015

On Github bithound / 2015-JSConf

I have to do WHAT to run this code?

Presented by Gord Tannerwww.bithound.io / @bithoundio

Gord Tanner

Co-Founder / CTO

bitHound

@gordtanner

What do new people bring?

Same issues with open or closed source projects

Nothing you don't know already

Where is your javascript?

Welcome to the team

git clone git@github.com:yourteam/project.git
          

now what?

First impressions matter

New Machine

Set up for success

Documentation: - what is important

README.md

Whiteboard sessions

Command line tooling

Code Comments

Vagrant

Kind of a love story

Multiple servers

Vagrant.configure(2) do |config|
  config.vm.define "app" do |app|
    app.vm.box = "trusty64"
    app.vm.provision "shell", path: "scripts/provision_app.sh"
    app.vm.network "private_network", ip: "10.10.11.11"
  end

  config.vm.define "worker1" do |worker|
    worker.vm.box = "trusty64"
    worker.vm.provision "shell", path: "scripts/provision_worker.sh"
    worker.vm.network "private_network", ip: "10.10.11.12"
  end

  config.vm.define "worker2" do |worker|
    worker.vm.box = "trusty64"
    worker.vm.provision "shell", path: "scripts/provision_worker.sh"
    worker.vm.network "private_network", ip: "10.10.11.13"
  end
end
So if you are building a distributed system, develop on a distributed system! Almost all virtualization environments right now allow you define multiple VMs and private networks.

Hide the fact you are using Vagrant

  • should feel like local development
  • port forwarding
  • host scripts
  • make it hard to mess up
#!/bin/bash

vagrant ssh --command "cd /vagrant && ./cmd.js $*"
Utility / proxy scripts to interact with your project inside the VM. You could call this a trampoline or a thunk, uh, if you lived through the win16 to win32 transition. (I didn't, but I was just after that and still had to deal with old developer documentation. $* is just the parameter list that this program has been called with itself.
vagrant ssh --command ""
$*

No one expects perfection

  • mongo install and allow remote connections
  • configure NFS for linux and osx
  • git http.postBuffer hack
  • weird issue with zmq native bindings
  • per-user file limit
  • system clock drift
apt-get install -y mongodb
perl 's/^bind_ip/#bind_ip/g' /etc/mongodb.conf
sudo service mongodb restart
          
# Make sure we've got NFS handy.
if [ $(uname) == 'Linux' ]; then
  apt-get install -y nfs-common
  apt-get install -y nfs-kernel-server
  apt-get install -y rpcbind
fi
git config --global http.postBuffer 524288000
        
# Fix the clock.
/etc/init.d/ntp stop
set +e
ntpdate pool.ntp.org
set -e
/etc/init.d/ntp start
        
## Up our per-user file limit.

if [[ -d /etc/limits.d ]]; then
  cp bh.conf /etc/limits.d/bh.conf
fi
        

Nag your users

Live Reload

I can't talk about this enough

nodemon, livereload, grunt-livereload, etc

Tests

More then just unit tests

How do you "test" the system

Always keep learning

bithound.io