Prod Deployment (Java Coderunner) - UQ-eLIPSE/shifoo-docs GitHub Wiki

Follow steps

ssh <uq_username>@mango.eait.uq.edu.au
triton profile set shifoox
triton instance create --name=shifoox-java22x-001 --tag='triton.cns.services=shifoox-java22x' --network=zones webproject z1-standard
ssh [email protected] # ssh into zone

Generate keys

ssh-keygen # Type /root/.ssh/id_rsa_coderunner_java
cat ~/.ssh/id_rsa_coderunner_java.pub

Copy key and place in deploy keys for coderunner-java repository. Repeat for coderunner-server

eval "$(ssh-agent -s)" # Start ssh agent
ssh-add ~/.ssh/id_rsa_coderunner_python
git clone [email protected]:UQ-eLIPSE/coderunner-java.git

Configuration

cd coderunner-java
cp config.json.example config.json
vim config.json

Ensure the json file looks like:

{
    "API_KEY": "SECRET_KEY",
    "PORT": 8070,
    "CODERUNNER_RUN_JAVA_SCRIPT": "/home/monkey/bin/run_java.sh",
    "CODERUNNER_TEMP_DIR": "/home/monkey/tmp",
    "MAX_PROC_TIMEOUT": 30000
}

Build (still in coderunner-java dir)

ssh-add -D # Clears all identities
ssh-add ~/.ssh/id_rsa_coderunner_server
yarn && yarn build

Install packages

apt update
apt upgrade --yes
wget https://download.oracle.com/java/22/latest/jdk-22_linux-x64_bin.deb
apt autoremove --yes
apt install htop

Install Java 22

apt --fix-broken install
sudo apt install ./jdk-22_linux-x64_bin.deb

Check version

java --version
# java 22.0.2 2024-07-16
# Java(TM) SE Runtime Environment (build 22.0.2+9-70)
# Java HotSpot(TM) 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing)

Create monkey User

adduser --disabled-password --gecos "" monkey
mkdir /home/monkey/{app,bin,tmp}
cp dist/config.json /home/monkey/
cp -rt /home/monkey/ lib node_modules
cp -rt /home/monkey/app/ dist/src/*
cp -rt /home/monkey/bin/ run_java.sh
chown -R monkey:monkey /home/monkey

System config vim /etc/systemd/system/monkey.service Paste the following

[Unit]
Description=ShiFoo Java22x Monkey
[Service]
Type=simple
User=monkey
WorkingDirectory=/home/monkey/tmp
ExecStart=/usr/bin/node /home/monkey/app/index.js
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

vim /etc/nginx/frameworks-enabled/monkey.conf Paste the following

location /ping { access_log off; return 200 'pong'; }
location /run { if ( $request_method = 'POST' ) { proxy_pass http://localhost:8070; } }

Disable sso

  1. vim /etc/nginx/conf.d/auth.conf
  2. Comment line 19 # default "allow:user:*";
  3. Uncomment line 20 (disables SSO): default "allow:*";
  4. After :wq Run nginx -t. Make sure the syntax in the conf file is ok and the test is successful
  5. systemctl restart nginx Monkey services
systemctl enable monkey
systemctl daemon-reload
systemctl restart nginx
systemctl restart monkey

Adding rsyslog

syslog is the default syslogd on Debian systems and allows us to help debug any future issues

apt-get install rsyslog -y
systemctl enable rsyslog
systemctl start rsyslog

vi /etc/rsyslog.conf Find and uncomment the following lines to make your server listens to the udp and tcp ports in the MODULES section as shown below; Make sure to also add the $template line below input(type="imtcp" port="514")

...
#################
#### MODULES ####
#################
...

# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")

# provides TCP syslog reception
module(load="imtcp")
input(type="imtcp" port="514")
$template RemInputLogs, "/var/log/remotelogs/%FROMHOST-IP%/%PROGRAMNAME%.log"
*.* ?RemInputLogs        ### ADDME
systemctl restart rsyslog
systemctl status rsyslog # Should be active
tail -f /var/log/syslog # To view logs

Load balancing

triton image create --description='Shifoo Java22 executor' --wait --json shifoox-java22x-001 shifoox-java22x 1.0.0
triton instance create --name=shifoox-java22x-002 --tag='triton.cns.services=shifoox-java22x' --network=zones --affinity='instance!=shifoox-java22x-001' shifoox-java22x z1-standard
triton instance create --name=shifoox-java22x-003 --tag='triton.cns.services=shifoox-java22x' --network=zones --affinity='instance!=shifoox-java22x-001' --affinity='instance!=shifoox-java22x-002' shifoox-java22x z1-standard
triton instance create --name=shifoox-java22x-004 --tag='triton.cns.services=shifoox-java22x' --network=zones --affinity='instance!=shifoox-java22x-001' --affinity='instance!=shifoox-java22x-002' --affinity='instance!=shifoox-java22x-003' shifoox-java22x z1-standard
triton instance create --name=shifoox-java22x-005 --tag='triton.cns.services=shifoox-java22x' --network=zones --affinity='instance!=shifoox-java22x-001' --affinity='instance!=shifoox-java22x-002' --affinity='instance!=shifoox-java22x-003' --affinity='instance!=shifoox-java22x-004' shifoox-java22x z1-standard

zinfo shifoox-java22x to view all the create instances

To test each zone, refer to https://github.com/UQ-eLIPSE/shifoo-docs/wiki/Coderunners-zone-testing