Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marcello Prattico Astrochimp

🏠
Working from home
View GitHub Profile
View gist:9a28daa40f7497728bfba6a3f46b213c
### Keybase proof
I hereby claim:
* I am Astrochimp on github.
* I am mprattico (https://keybase.io/mprattico) on keybase.
* I have a public key whose fingerprint is 7392 2697 C341 4A95 34C6 69A7 806E 4DAA 6676 CC22
To claim this, I am signing this object:
@Astrochimp
Astrochimp / cloudSettings
Last active Oct 9, 2019
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2019-01-22T22:55:44.526Z","extensionVersion":"v3.2.4"}
View Swapi.js
import React, { Component } from 'react'
import axios from 'axios'
class Swapi extends Component {
constructor (props) {
super(props)
this.state = {
character: {},
movielist: [],
View Emoji.js
import React, { Component } from 'react'
import emojilist from '../data/emoji.json'
class Emoji extends Component {
constructor (props) {
super(props)
this.state = {
emojivalue: '',
emojidisplay: []
}
View flatten-multi.js
function flattenArray(arr) {
const flattened = [].concat(...arr);
return flattened.some(item => Array.isArray(item)) ?
flattenArray(flattened) : flattened;
}
View getmean.js
const popular = arr.sort((a, b) =>
arr.filter(v => v===a).length
- arr.filter(v => v ===b).length
).pop()
View deployUser.md

(wherever it says url.com, use your server's domain or IP)

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

View node-deploy-as-upstart-service.md

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start
View flightplan-deploy.md

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file