-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.txt
120 lines (106 loc) · 4.37 KB
/
setup.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
## Copyright 2017 Inca Roads LLC. All rights reserved.
## Use of this source code is governed by licenses granted by the
## copyright holder including that found in the LICENSE file.
##
## TO CREATE A NEW INSTANCE
##
## 1. Create the instance of UBUNTU Server 16.04LTS, t2.micro using default settings
## so that it has a public IP address, and using safecastdev key
## 2. Assign the correct security group, i.e.
## In Actions / Networking / Change Security Groups, select the TTSERVE security group and Assign Security Groups
## 3. Add the instance to both the 80 and 8080 load balancer Target Groups
## 4. Make sure that locally you have the safecastdev.pem key on your keychain ie
## ssh-add -K /keybase/private/rozzie,matschaffer/safecastdev.pem
## 5. SSH into the instance using ubuntu@<instance-domain-name>
##
##
## FIRST TIME INSTANCE SETUP PROCEDURE
##
## Update the updater
sudo apt update
## Install GIT so we can pull new versions
sudo apt install git --assume-yes
## Install GOLANG so we can rebuild our code
sudo apt install golang-go --assume-yes
## Upgrade to go 1.12 (for module support)
## instructions: https://github.com/golang/go/wiki/Ubuntu
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go
## Install NFS so we can mount an EFS filesystem on amazon
sudo apt-get install nfs-common --assume-yes
## Verify that the version of GOLANG is at least go1.6.2
go version
## Add these to the end of ~/.profile with NANO editor
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
export TT=$GOPATH/src/github.com/safecast/ttserve
## Fetch our app package
mkdir $HOME/go && mkdir $HOME/go/src && mkdir $HOME/go/src/github.com && mkdir $HOME/go/src/github.com/safecast && cd $HOME/go/src/github.com/safecast
git init
git clone https://github.com/safecast/ttserve
## Use "crontab -e" and add this line
@reboot screen -dmS ttserve $HOME/go/src/github.com/safecast/ttserve/run.sh
## Add new relic
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install newrelic-sysmond
sudo nrsysmond-config --set license_key=<key>
sudo systemctl start newrelic-sysmond
## Just make sure everything is up to date
sudo apt-get upgrade -y
## Make sure that this linux instance doesn't run out of disk space because of accumulation of linux headers
## in /usr/src by setting this to "true":
sudo emacs /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Remove-Unused-Dependencies "true";
## By the way, if you ever need to clean up disk space because you forgot to do this:
## remove a few folders in /usr/src manually via
## sudo rm -rf linux-headers-4.4.0-101
## now that there is space, download the LATEST headers
## sudo apt-get -f install
## now that the latest headers are installed, purge the older ones
## sudo apt autoremove --purge
## verify everything works after a restart
## sudo shutdown -r 0
## REBOOT THE AWS INSTANCE
## You can then come back via SSH and use 'screen' to look around
## Do this to see if our screen is already running:
screen -ls
## If you see the 'ttserve' instance, do:
screen -r
## If, while watching console, you want to return to main screen console, press:
^a d
## If you do NOT see the ttserve instance, do:
screen -S ttserve
cd $TT && ./run.sh
## If, while watching console, you want to force a restart/refresh from git, press:
^c
## If, while watching the console, you want to exit SSH, press:
^a d
exit
## Note that if you STOP the any instance except for TTSERVE0, the address will change
## so that you will need to SSH into a different domain name. Other than that, the
## "ANYTIME SSH'ING" procedure above will work to get it going again after Start.
## SCREEN COMMAND REFERENCE
## Running in background
## create a new screen and switch to it
screen -S ttserve
## list screens
screen -ls
## delete the current screen and logout
exit
## detach screen (leave and go back to main shell)
screen -d
## detach screen when not at a command line
^a d
## go back to the one other detached screen
screen -R
## go back to detached screen
screen -r <pid# or name>
## detach a specific attached screen
screen -d <pid# or name>
## go back to a specific attached screen
screen -d -r <pid# or name>
## kill all screens and current window
screen -X quit