Code Monkey home page Code Monkey logo

strogsvr's Introduction

TO SETUP YOUR DEV ENVIRONMENT

On Mac, agree to XCode

sudo xcodebuild -license

Install Tools

You'll need NodeJS v12+, npm, git, nodemon (global install), an editor like Sublime 3.2.1+ You can use brew for most of these.

Git Credentials

On Mac, type Cmd-Space and find Keychain Access Within Keychain search for "github" Set the URL to https://github.com and the username and password appropriately

Clone the repos

cd ~/code
git clone https://github.com/wdemarest/strogsvr
git clone https://github.com/wdemarest/candyhop
git clone https://github.com/wdemarest/reactorRescue
git clone https://github.com/wdemarest/shadowStone
git clone https://github.com/wdemarest/turmoil

Secret Encryption

This makes it so that a Sublime plugin will auto-encrypt any changes you make to .secret.hjson files

npm install -g node-cipher
cd ~/code/strogsvr
tools/util.sh install

Setup your environment variables

Edit your ~/.profile and make sure it contains

export STROG_CONFIG_ID=your_config_name_for_example_bob
export STROG_PASSPHRASE=passphrase_kept_in_my_pwd_file

Setup your strogsvr/config.<STROG_CONFIG_ID>.secret.hjson file based on config.template.hjson

Ken has all the details in his password file under strogsvr. These files are excluded from version control, but when you change them a Sublime plugin will save them as encrypted .cast5 files

Just in case that doesn't work, here are the methods to encrypt and decrypt them. Encrypt: nodecipher encrypt "config.production.secret.hjson" "config.production.cast5" <<< "$STROG_PASSPHRASE"

Decrypt: nodecipher decrypt "config.production.cast5" "config.production.secret.hjson" <<< "$STROG_PASSPHRASE"

Sublime Config

Click Sublime / Preferences / Settings, and set all of the following:

{
	"auto_complete": false,
	"auto_match_enabled": false,
	"tab_completion": false,
	"word_wrap": "false"
}

Install Sublime Hooks and Hjson highlighting:

  1. Install "Package Control" in Sublime: https://packagecontrol.io/installation
  2. Paste that text into Sublime console: Ctrl+Backtick then paste
  3. Restart Sublime.
  4. Sublime/Preferences/Package Control; type "Package Install" and choose Hjson
  5. Sublime/Preferences/Package Control; type "Package Install" and choose OnSave

Mac HID setup

defaults write -g InitialKeyRepeat -int 10
defaults write -g KeyRepeat -int 1
defaults write -g com.apple.keyboard.fnState -int 1
Then logout & login to make the changes take effect

If you use a roller mouse:

  • Uninstall any Logitech Control Center (LCC)
  • Install SteerMouse
  • In SteerMouse, set Wheel / Roll Up to "Scroll Up 5.0"
  • In SteerMouse, set Wheel / Roll Down to "Scroll Down 5.0"

TO SETUP A NEW SERVER

  1. If you need to generate a keypair (typically you'll let AWS do this for you)
openssl genrsa -des3 -out strog.pem 2048
openssl rsa -in strog.pem -outform PEM -pubout -out strog.pub
chmod 400 ~/.ssh/strog.pub
chmod 400 ~/.ssh/strog.pem
  1. Boot a fresh Ubuntu instance at EC2
Visit aws.amazon.com, login and access EC2
Click [Launch]
Pick "Ubuntu Server 16.04 LTS (HVM), SSD Volume Type"
Pick "t2.micro - free tier eligible"
Change Security to allow "outbound all" and "inbound port 22" and "inbound port 80"
Accept all other defaults for storage, etc.
Pick [Launch], and create a new keypair
Save it as ~/.ssh/strog.pem
chmod 400 ~/.ssh/strog.pem

2.1 Be sure that Route53 has strog.com set up properly to point at the IP address of this server.

  1. Setup the .pem file From local osx terminal:
cd ~/.ssh
pico strog.pem
copy/paste the private key you used to boot the AWS machine into that file
ctrl-x  y  <enter>
  1. Secure shell to the remote This assumes you have strog.com setup in Route 53 to point to the booted IP address.
ssh [email protected] -i ~/.ssh/strog.pem
  1. Install NodeJs and Git on the remote
sudo apt-get update
sudo apt-get install git
sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install -g supervisor

5.5 Install Redis on the remote

sudo apt-get install redis-server
sudo systemctl enable redis-server.service
sudo vim /etc/redis/redis.conf
Consider these values: maxmemory 256mb
Consider these values: maxmemory-policy allkeys-lru
sudo systemctl restart redis-server.service
  1. Clone all repos
cd ~
git clone https://github.com/wdemarest/strogsvr
git clone https://github.com/wdemarest/candyhop
git clone https://github.com/wdemarest/reactorRescue
git clone https://github.com/wdemarest/shadowStone
git clone https://github.com/wdemarest/turmoil

6.1 Cache passwords for each

cd ~/strogsvr
git config credential.helper store ; git pull
cd ~/candyhop
git config credential.helper store ; git pull
cs ~/reactorRescue
git config credential.helper store ; git pull
cs ~/shadowStone
git config credential.helper store ; git pull

6.2 Install node packages in each

cd ~/strogsvr
npm install
cd ~/candyhop
npm install
cs ~/reactorRescue
npm install
cs ~/shadowStone
npm install
  1. Redirect port 8080 to port 80. We don't want to run the server as root, but ports below 1024 are root only, so this is the safe workaround. Note that as of 2019-10-18 these commands are always run during a ./svr start
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
  1. Setup the passphrase on the remote Edit ~/.profile and make sure it contains
export STROG_PASSPHRASE=passphrase_kept_in_my_pwd_file
  1. Edit the remote ~/.ssh/known_hosts file and paste appropriate public keys

  2. Get a Mandrill account

  1. Test the server is working on the remote
nodejs ./server.js

then launch your browser and visit the appropriate IP address on port 80.

Running the Server

While logged in to the koding.com server, or any machine that has its public key on the strog.com server, run:

./svr [ deploy app | stop | start | restart | status | log | login | fetch | dev ]
deploy app can be strogsvr, candyhop, reactorRescue, shadowStone
  • deploy [strogsrv|candyhop|reactorRescue|shadowStone] - deploys to and overwrites server
  • config [strogsrv|shadowStone] - copies config.production.secret.hjson to server
  • log [strogsvr|shadowStone] - emits the last 100 log entries from the server
  • logcache [strogsvr|shadowStone] - copies the remote log file to ./logcache, overwriting
  • start - starts the servers
  • restart - re-starts the servers
  • stop - stops the servers
  • status - shows the status of the running servers
  • update - updates the Ubuntu OS with security and other patches
  • login - shell to the server
  • fetch - fetch server-only files into the ./archive directory, as backups
  • dev - starts strogsvr on your dev machine

Server Maintenance

From time to time you must make sure that Ubuntu has all needed packages updated for security. From /strogsvr run:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Monitoring

The service UptimeRobot monitors strog.com. You can find it at

https://uptimerobot.com/
Username: [email protected]
Password: <in lastpass>

To sign players up

  1. Visit http://strog.com
  2. Login with the username "admin" and the admin password
  3. http://strog.com/signup.html

Public Key

For reference, here is the public key to connect using strog.pem:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCdzhJlKt5CPCB0oX5Jt8ctjgr2Scdw0ARKb4c6hW3rqHzGU8K7q+W4ulVIGJzrCB5o1lVvcfzEPu37rdon1VngZMHAhEtf5SyNxIbOBqXrCpge2UvMUDW8fxOez1O+pVotx4IYoC1jzwfJEWD6LFmGUuKVxTxbkUCNmPiosECGBMEHvrsOWsFL9vUXhp/WrnMPP/KGCMN6Wm0W1kxlv8ISp6tQ8Zi3u4by0C+5FSKW7Ta5Z9EzdxKRMVyPw0Kw3Y9QiLYEoSkM5B3UcXtK+eCL2AR8nE/ul/kRdG/QfDrW3Bf+QDX5MClCVXtk0qIn7q/U65kr4embszEwOBzB8BAB strog

strogsvr's People

Contributors

kdemarest avatar wdemarest avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.