Programming from A to Z

about syllabus All example source code

Notes on Deploying to EC2

Creating a server instance




$ chmod 400 yourkeyfile.pem
$ ssh -i "yourkeyfile.pem" ubuntu@

Replace “” with your “public IP” as shown in your EC2 console.

Installing node and running your bot

$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo apt-get install npm
$ sudo ln -s `which nodejs` /usr/bin/node
$ npm install


$ node bot.js
$ sudo npm install forever -g
$ forever start bot.js

If you want to specify the logging files for any console output:

$ forever -o out.log -e err.log start bot.js

And you can also stop, restart, and list as follows:

$ forever stop bot.js
$ forever restart bot.js
$ forever list
$ forever stopall

Using Processing/Java

This comes from the headless Processing wiki.

$ sudo apt-get install default-jre

It may be that the default JRE is not compatible in which case you can try:

$ sudo apt-add-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install xvfb libxrender1 libxtst6 libxi6
$ sudo Xvfb :1 -screen 0 1024x768x24
$ export DISPLAY=":1"

This will also only run for as long as you have terminal open. To have it run in the background while you launch your bot:

$ sudo nohup Xvfb :1 -screen 0 1024x768x24 &
$ export DISPLAY=":1"
// You could use 'pwd' to determine the absolute path
var cmd = 'folder/sketchname';
exec(cmd, processing);
sudo ./'your_applications_name'
chmod 777 'your_applications_name'