# V3 Server Fleets

## The process:

1. Determine a new name for the server fleet (e.g. $name = "ThisIsATest")
2. Go to Amazon and create a new key pair using the name from 1 (ThisIsATest.pem)
3. Save the resulting .pem file.

TODO - ask David!


## Copy terraform scripts to deploy the server fleet.

Copy terraform files to the jenkins server:

```
JENKINS_USER_NAME='ubuntu'
JENKINS_SERVER_IP='ec2-34-217-118-93.us-west-2.compute.amazonaws.com'
JENKINS_DEST_PATH=/home/ubuntu
RSYNC_DEST=$JENKINS_USER_NAME@$JENKINS_SERVER_IP:$JENKINS_DEST_PATH
scp -i "$BIGSCREEN_DROPBOX_PATH/Server_Keys/_Jenkins/JenkinsBuildServerA.pem" -r ./arch5-media-only $RSYNC_DEST/terraform/WhiskeyMediaGroupC
```

## Jenkins

```
ssh -i "$BIGSCREEN_DROPBOX_PATH/Server_Keys/_Jenkins/JenkinsBuildServerA.pem" ubuntu@ec2-34-217-118-93.us-west-2.compute.amazonaws.com
```


# Whiskey Main - MediaServerGroupB

terraform plan -var="stage=WhiskeyMain" \
                -var="cloudmedia_count=5" \
                -var="cloudmedia_key_name=WhiskeyMain" \
                -var="suffix=GroupB" \
                -var="cloudmedia_instance_type=c5.large"

terraform apply -var="stage=WhiskeyMain" \
                -var="cloudmedia_count=5" \
                -var="cloudmedia_key_name=WhiskeyMain" \
                -var="suffix=GroupB" \
                -var="cloudmedia_instance_type=c5.large"


# Whiskey Main - MediaServerGroupC

terraform plan -var="stage=WhiskeyMain" \
                -var="cloudmedia_count=10" \
                -var="cloudmedia_key_name=WhiskeyMain" \
                -var="suffix=GroupC" \
                -var="cloudmedia_instance_type=c5.large"

terraform apply -var="stage=WhiskeyMain" \
                -var="cloudmedia_count=10" \
                -var="cloudmedia_key_name=WhiskeyMain" \
                -var="suffix=GroupC" \
                -var="cloudmedia_instance_type=c5.large"

# Nginx setup

### Limits

Edit `/etc/nginx/nginx.conf` and add the following line above the `events` section:

```
worker_rlimit_nofile 30000; # <--- Add or change this line

events {
    ...
```

Also set the following in the `events` section of the same file, `/etc/nginx/nginx.conf`:

```
events {
	worker_connections 8192; # <--- Add or change this line
	# multi_accept on;
}
```

Edit `/etc/security/limits.conf` and add the following (note: there is a tab between each column) at the bottom of the file:

```
nginx		soft	nofile		10000
nginx		hard	nofile		30000
```

Edit `/etc/sysctl.conf` and add the following line at the bottom of the file:

```
fs.file-max = 70000
```

Update the processes:

```
sysctl -p
```

Finally, restart nginx:

```
sudo systemctl restart nginx
```