-
Notifications
You must be signed in to change notification settings - Fork 429
Expand file tree
/
Copy pathsetup-ce-router.sh
More file actions
executable file
·63 lines (48 loc) · 1.75 KB
/
Copy pathsetup-ce-router.sh
File metadata and controls
executable file
·63 lines (48 loc) · 1.75 KB
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
#!/bin/bash
set -exuo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Use common setup but skip NFS and CEFS (routers don't need filesystem mounts)
export SKIP_NFS_SETUP=1
export SKIP_CEFS_SETUP=1
# Use router-specific SSM parameters for Papertrail logging
export LOG_DEST_HOST_PARAM="/compiler-explorer/logDestHostRouter"
export LOG_DEST_PORT_PARAM="/compiler-explorer/logDestPortRouter"
"${DIR}/setup-common.sh"
apt-get -y update
apt-get -y install \
curl \
jq \
nginx
# Install Node.js (arm64 build matches the Lambda runtime major)
pushd /opt
TARGET_NODE_VERSION="v$(cat "${DIR}/node-version")"
echo "Installing node ${TARGET_NODE_VERSION}"
curl -sL "https://nodejs.org/dist/${TARGET_NODE_VERSION}/node-${TARGET_NODE_VERSION}-linux-arm64.tar.xz" | tar xJf - && mv "node-${TARGET_NODE_VERSION}-linux-arm64" node
popd
# Configure nginx for health checks
cp /infra/nginx/ce-router.conf /etc/nginx/nginx.conf
systemctl restart nginx
# Install systemd service
cp /infra/init/ce-router.service /lib/systemd/system/ce-router.service
systemctl daemon-reload
systemctl enable ce-router
# Create ce user for running the router
adduser --system --group ce
# Don't set hostname here - let cloud-init handle it like other instances
# Configure CloudWatch logging
mkdir -p /var/log/ce-router
chown ce:ce /var/log/ce-router
# Configure AWS credentials location
mkdir -p /home/ce/.aws
echo -e "[default]\nregion=us-east-1" > /home/ce/.aws/config
chown -R ce:ce /home/ce/.aws
# Memory and network optimizations
mkdir -p /etc/sysctl.d
cat >/etc/sysctl.d/99-ce.conf <<EOF
vm.min_free_kbytes=65536
net.core.rmem_max=268435456
net.core.wmem_max=268435456
net.ipv4.tcp_rmem=4096 65536 268435456
net.ipv4.tcp_wmem=4096 65536 268435456
EOF
sysctl -p /etc/sysctl.d/99-ce.conf