From dc12625176b76d24a4392d66aa03a5e616aa439a Mon Sep 17 00:00:00 2001 From: Michael Truell Date: Fri, 23 Dec 2016 19:13:26 -0500 Subject: [PATCH] First stab at adding in worker/manager documentation (won't work) --- CONTRIBUTING.md | 29 +++++++++++++++++++++++++++-- website/api/manager/ManagerAPI.php | 2 +- website/sql/dummyData.sql | 3 ++- website/sql/importDummyData.sh | 12 +++--------- website/sql/install.sh | 3 +-- worker/worker.py | 2 -- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 05dbb3f1c..bc6ea0051 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,9 @@ Edit [this whitelist](https://github.com/HaliteChallenge/Halite/edit/master/webs - `website/` - The website that hosts the competition. Includes the API that manages the game servers. - `worker/` - The source for the worker servers that compile bots and run games safely -## Installing the website on Ubuntu +## Installation + +### Installing the website on Ubuntu Clone the repo: @@ -33,7 +35,7 @@ Run the website install script with root user permissions. This will install php cd website; sudo ./install.sh -Run the database install script with root user permissions. This will install mysql and insert our schema into a database titled Halite. +Run the database install script with root user permissions. This will install mysql, insert our schema into a database titled Halite, and import some dummy users. cd sql; sudo ./install.sh @@ -44,3 +46,26 @@ Create a `halite.ini` file using your favorite text editor in the root project d username = YOUR_LOCAL_MYSQL_USERNAME password = YOUR_LOCAL_MYSQL_PASSWORD name = Halite + +### Setting up the manager and worker on Ubuntu + +We assume that you have already followed "Installing the website on Ubuntu." + +Run the worker install script. It will install some required libraries, switch your default compiler to g++4.9, build our docker sandbox, and enable swap memory: + + cd worker; sudo ./install.sh + +Add these lines to your `halite.ini` file: + + [hce] + managerURl = http://localhost/website/api/manager/ + apiKey = 1 + secretFolder = blah_blah_blah + +Reboot your system (because of the enabling of swap memory): + + sudo reboot + +Start a worker: + + cd worker; sudo python3 worker.py diff --git a/website/api/manager/ManagerAPI.php b/website/api/manager/ManagerAPI.php index a4ab2e500..2722c11ae 100644 --- a/website/api/manager/ManagerAPI.php +++ b/website/api/manager/ManagerAPI.php @@ -185,7 +185,7 @@ protected function game() { } - $s3Client->putObject($args); + //$s3Client->putObject($args); } // Check that we arent stoing too many games in db diff --git a/website/sql/dummyData.sql b/website/sql/dummyData.sql index 53350254c..6b42ad6ab 100644 --- a/website/sql/dummyData.sql +++ b/website/sql/dummyData.sql @@ -1,3 +1,4 @@ DELETE FROM User; -INSERT INTO User (username, email, compileStatus, isRunning, language, organization) VALUES ('John Doe', 'jane_doe@gmail.com', 0, 1, 'Java', 'Other'), ('Jane Doe', 'jane_doe@gmail.com', 0, 1, 'Python', 'Other'); +INSERT INTO User (userID, username, email, compileStatus, isRunning, language, organization) VALUES (2609, 'erdman', 'abc@gmail.com', 0, 1, 'Python', 'Other'), (1017, 'djma', 'abc@gmail.com', 0, 1, 'Java', 'Other'), (3063, 'daniel-shields', 'abc@gmail.com', 0, 1, 'Python', 'Other'); +INSERT INTO Worker (apiKey, ipAddress) VALUES (1, "127.0.0.1"); diff --git a/website/sql/importDummyData.sh b/website/sql/importDummyData.sh index 04f4346a9..21f4a8f8d 100755 --- a/website/sql/importDummyData.sh +++ b/website/sql/importDummyData.sh @@ -1,11 +1,5 @@ #!/bin/bash -echo "Are you sure that you want to run this script??? It will erase everything in your db. Answer [y/n]:" - -read ANSWER - -if [ "$ANSWER" == "y" ]; then - echo "drop database Halite; create database Halite;" | mysql -u root - mysql -u root Halite < schema.sql - mysql -u root Halite < dummyData.sql -fi +echo "drop database Halite; create database Halite;" | mysql -u root -p +mysql -u root Halite < schema.sql -p +mysql -u root Halite < dummyData.sql -p diff --git a/website/sql/install.sh b/website/sql/install.sh index b7f3dd2e1..e9a5be4c0 100755 --- a/website/sql/install.sh +++ b/website/sql/install.sh @@ -1,5 +1,4 @@ sudo apt-get install -y mysql-server echo "Starting MySql setup" -echo "create database Halite;" | mysql -u root -p -mysql -u root -p Halite < schema.sql +./importDummyData.sh diff --git a/worker/worker.py b/worker/worker.py index c7b6f8e88..6194c2f6a 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -31,8 +31,6 @@ parser.read("../halite.ini") RUN_GAME_FILE_NAME = "runGame.sh" -HALITE_EMAIL = parser["email"]["email"] -HALITE_EMAIL_PASSWORD = parser["email"]["password"] SECRET_FOLDER = parser["hce"]["secretFolder"] def makePath(path):