|
Page last edited by Claire Elizabeth Joyce (celjoy) 08/10-2014
This page contains instruction for setting up an Amazon EC2
instance for running your bot. Amazon's machine is free of charge
for a year, and is a great little computer with one processor, 1GB
of RAM and 8GB of storage space, which should be more than enough
for the course. And, most importantly it will allow you to run the
bot code 24/7, without having to keep your computer running and
connected to the internet.
STEP 1: Creating an instance
- Go to AWS Free Tier
webpage and press Get Started Today
- Open a new Amazon account, register with your credit card
(nothing will be charged)
- Under Compute & Networking select Amazon EC2 and then
Launch Instance
- Select an Ubuntu Server 14.04 and in the next screen click
Review and Launch, then Launch
- When prompted about key pair select "Create a new key pair" and
name it for example "ec2 keypair", then download it.
- Click Launch instances
- In the next screen click "View instances" to review the list of
your machines
STEP 2: Configuring the instance
In this step we will install all necessary software on your
machine to make sure it can host a twitter bot.
- Follow the instructions from
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html
for your own operating system to connect to your machine
- Once you have connected paste this command into console to
download Anaconda Python distribution:
wget
http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-2.0.1-Linux-x86_64.sh
- Paste this into console to install it:
bash Anaconda-2.0.1-Linux-x86_64.sh
- You can press q when you are done reading terms and
conditions.
- Say yes to license terms, then confirm the
default location and say yes to prepending
anaconda location to your bashrc file
- Now disconnect from your machine by typing
exit
- Connect again and perform the following commands:
sudo apt-get install python-pip
pip install twitter
sudo apt-get install git
sudp apt-get install sqlite3
git clone
https://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition.git
- Congratulations, your machine is ready to host your bot!
STEP 3: Configuring the logging
In this step we will set up a logger that will keep track of
your bot's actions: the followers and friends, and the tweets your
bot creates.
- Log into your EC2 instance and move to the ubuntu user home
folder:
cd /home/ubuntu/
- download the setup file:
wget http://raman.imm.dtu.dk/pisa/twitter/settings.py -O
/home/ubuntu/settings.py
- Use your favorite editor to edit the setup.py file and fill in
the gaps (use an integer for user_id, for example USER_ID =
123123)
- Download the logging script:
wget http://raman.imm.dtu.dk/pisa/twitter/runner.sh -O
/home/ubuntu/runner.sh
- Give the logging script run permissions:
chmod +x runner.sh
- Run it once to see if everything works:
./runner.sh
- After running, activity.log file will be created in the home
folder, you can inspect it to see if everything is fine.
- If you get authentication errors, make sure that the
information in settings.py is correct.
- Edit your crontab so that the runner.sh is run every hour, for
example by adding this line:
0 * * * * /home/ubuntu/./runner.sh
This page will be permanently deleted and cannot be recovered. Are you sure?
|