Appearance
EC2 setup
Creating an Amazon EC2 instance within the AWS Free Tier involves selecting specific, eligible configurations to avoid incurring charges. During setup the items noted below are adjusted. All other settings are left as default values.
- Name: Api3 Social Apps
- OS: use
Amazon Linux - AMI: use
Amazon Linux 2023 kernel-6.12 - Architecture:
64-bit (x86) - Instance type:
t3.micro - Key pair (login):
id_api3_social_apps - Security group: Select existing security group
launch-wizard-1, this allows only ssh connection on port 22.
Install global packages on EC2
Nodejs is used by the Discord bot along with other packages.
- nvm: Nodejs runtimes
- pnpm: package management
- git: repo access
- pm2: Nodejs instance management
Install nvm, Nodejs, npm, pnpm
See AWS the doc here. Check the nvm GitHub repo for the latest version. Update the curl command that installs nvm with the latest version if needed (e.g. v0.40.1 > v0.40.3).
Lastly install pnpm globally.
sh
npm install -g pnpmInstall git
If Git is not installed, install it using the package manager for Amazon Linux (e.g., sudo yum install git -y).
Install pm2
pm2 is used for process management of multiple Nodejs instances. This allows multiple Nodejs instance processes to live beyond the closure of an SSH client connection. pm2 is a Nodejs centric package.
sh
npm install -g pm2Local repositories
Both the api3-discord-bot and api3-telegram-bot repos need to be cloned to the EC2 instance. Note that pnpm was the preferred package management tool used to install dependencies for the repos.
sh
// Use the http connect string from github for each repo
// Use pnpm as the package manager
cd ~
git clone https://github.com/api3dao/api3-discord-bot.git
cd api3-discord-bot
pnpm install
cd ~
git clone https://github.com/api3dao/api3-telegram-bot.git
cd api3-telegram-bot
pnpm install
