New cloud9 instructions and steps from websockets update

This commit is contained in:
Jeremy Zhang 2017-09-25 00:02:05 +00:00
parent f035308e17
commit 70aae0ab22
2 changed files with 31 additions and 20 deletions

View File

@ -15,10 +15,11 @@ For those who would like to run the codebase yourself, you may follow the instru
7. Set the `Clone from Git or Mercurial url` to `git@github.com:TitanEmbeds/Titan.git` This should pull titan to your workspace. 7. Set the `Clone from Git or Mercurial url` to `git@github.com:TitanEmbeds/Titan.git` This should pull titan to your workspace.
8. Right click `cloud9_install.sh` file at the left sidebar and click run. This will set everything up. 8. Right click `cloud9_install.sh` file at the left sidebar and click run. This will set everything up.
9. Afterwards, just edit the respective config.py files in the webapp/discordbot directories and you are ready to go! 9. Afterwards, just edit the respective config.py files in the webapp/discordbot directories and you are ready to go!
10. Now you're ready to run Titan... webapp! To make the webapp to work, rightclick `run_c9.py` file and click run. Congratz! It will tell you the exact url where your stuff is running at. 10. Now you're ready to run Titan! To make the webapp to work, (1)Double click run_c9.py in the webapp folder, (2)At the menu bar: hit Run->Run With->Python3.5, to start the webapp.
11. For discord bot, you can change the directory to the discordbot `cd discordbot/` and run `python3.5 run.py` to start the bot from the bash console! 11. Do the same thing with run.py in the discordbot folder
12. To make the login system work, go back to your discord bot applications page... for the redirect uris, add these: `http://xxx.cs50.io/user/callback` and `http://xxx.cs50.io/user/dashboard`. Replacing the `xxx` with your subdomain url in the webapp. That outta make the login work! (Take note that there is no http**s** in http). 12. The console will show: wsgi starting up on `http://0.0.0.0:8080`. Click on that url and hit Open to view the local webapp.
Now that you set everything up, take a step back and learn some ubuntu/bash to get familiar with it. Some things like git commit/push/pull, etc might be helpful. Maybe you can get phpmyadmin and inspect the database yourself, in gui form <https://community.c9.io/t/setting-up-phpmyadmin/1723>. 13. To make the login system work, go back to your discord bot applications page... for the redirect uris, add these: `http://xxx.cs50.io/user/callback` and `http://xxx.cs50.io/user/dashboard`. Replacing the `xxx` with your subdomain url in the webapp. That outta make the login work! (Take note that there is no http**s** in http).
Now that you set everything up, take a step back and learn some ubuntu/bash to get familiar with it. Some things like git commit/push/pull, etc might be helpful.
## Pull Requesting ## Pull Requesting
If you do not have write access to the codebase, please make a fork of the project. Edit your changes on your fork and push it out onto GitHub. Afterwards, you may submit a pull request for your changes to be merged to the master branch (production). If you do however have write access to the repository, please create a branch and propose pull requests for me to merge into the production. If you do not have write access to the codebase, please make a fork of the project. Edit your changes on your fork and push it out onto GitHub. Afterwards, you may submit a pull request for your changes to be merged to the master branch (production). If you do however have write access to the repository, please create a branch and propose pull requests for me to merge into the production.

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "[C9Setup] Installing mysql, redis, and creating titan db table" echo "[C9Setup] Installing postgresql, redis, and creating titan db table"
cd ~/workspace/ cd ~/workspace/
mysql-ctl start sudo service postgresql start
mysql -u root -e "CREATE DATABASE titan;" psql -c "CREATE DATABASE titan WITH ENCODING 'UTF8' TEMPLATE template0"
sudo service redis-server start sudo service redis-server start
echo "[C9Setup] Copying config.py for webapp/discordbot and alembic.ini" echo "[C9Setup] Copying config.py for webapp/discordbot and alembic.ini"
@ -12,34 +12,44 @@ cp ~/workspace/webapp/alembic.example.ini ~/workspace/webapp/alembic.ini
echo "[C9Setup] Installing Titan dependencies" echo "[C9Setup] Installing Titan dependencies"
cd ~/workspace/ cd ~/workspace/
sudo python3.5 -m pip install -r requirements.txt sudo python3.5 -m pip install --upgrade pip
sudo python3.5 -m pip install alembic pymysql eventlet uwsgi sudo python3.5 -m pip install -U -r requirements.txt
sudo python3.5 -m pip install -U alembic psycopg2 eventlet
echo "[C9Setup] Auto populating alembic.ini database url and titan database table" echo "[C9Setup] Auto populating alembic.ini database url and titan database table"
cd ~/workspace/webapp cd ~/workspace/webapp
#sqlalchemy.url = mysql+pymysql://root@localhost/titan #sqlalchemy.url = postgresql:///titan
sed -i '32s/.*/sqlalchemy.url = mysql+pymysql:\/\/root@localhost\/titan/' ~/workspace/webapp/alembic.ini sed -i '32s/.*/sqlalchemy.url = postgresql:\/\/\/titan/' ~/workspace/webapp/alembic.ini
alembic upgrade head alembic upgrade head
echo "[C9Setup] Setting database uri for discordbot/config.py" echo "[C9Setup] Setting database uri for discordbot/config.py"
#'database-uri': "mysql+pymysql://root@localhost/titan", #'database-uri': "mysql+psycopg2:///titan?client_encoding=utf8",
sed -i "4s/.*/\'database-uri\': \"mysql+pymysql:\/\/root@localhost\/titan\",/" ~/workspace/discordbot/config.py sed -i "4s/.*/\'database-uri\': \"postgresql+psycopg2:\/\/\/titan?client_encoding=utf8\",/" ~/workspace/discordbot/config.py
echo "[C9Setup] Setting database uri and app location for webapp/config.py" echo "[C9Setup] Setting database uri and app location for webapp/config.py"
sed -i "11s/.*/\'database-uri\': \"mysql+pymysql:\/\/root@localhost\/titan\",/" ~/workspace/webapp/config.py sed -i "19s/.*/\'database-uri\': \"postgresql+psycopg2:\/\/\/titan?client_encoding=utf8\",/" ~/workspace/webapp/config.py
#'app-location': "/home/ubuntu/workspace/webapp/", #'app-location': "/home/ubuntu/workspace/webapp/",
sed -i "8s/.*/\'app-location\': \"\/home\/ubuntu\/workspace\/webapp\/\",/" ~/workspace/webapp/config.py sed -i "16s/.*/\'app-location\': \"\/home\/ubuntu\/workspace\/webapp\/\",/" ~/workspace/webapp/config.py
#'webosockets-mode': "eventlet",
sed -i "21s/.*/\'websockets-mode\': \"eventlet\",/" ~/workspace/webapp/config.py
echo "[C9Setup] Making sure everything can be ran" echo "[C9Setup] Making sure everything can be ran"
cd ~/workspace/ cd ~/workspace/
sudo chmod -R 777 * sudo chmod -R 777 *
echo "[C9Setup] Creating Cloud9 Python3.5 runner"
mkdir .c9/runners
touch .c9/runners/Python3.5.run
echo '{ "cmd" : ["python3.5", "$file", "$args"], "info" : "Started $project_path$file_name on Python v3.5", "env" : {}, "selector" : "source.py" }' > .c9/runners/Python3.5.run
echo "[C9Setup] Resetting everything to the master branch"
git reset --hard origin/master
echo "------------------------------" echo "------------------------------"
echo "Cloud9 Installation Done!!!!!" echo "Cloud9 Installation Done!!!!!"
echo "If there are no errors, then you may proceed by editing the config.py files in the webapp and discordbot directories with your discord bot tokens, etc." echo "If there are no errors, then you may proceed by editing the config.py files in the webapp and discordbot directories with your discord bot tokens, etc."
echo "Remember that your database uri is: mysql+pymysql://root@localhost/titan"
echo "" echo ""
echo "After you finished editing those files, you may right click on run_c9.py and click run in the menu to start the webapp." echo "After you finished editing those files, you may (1)Double click run_c9.py in the webapp folder, (2)At the menu bar: hit Run->Run With->Python3.5, to start the webapp"
echo "To run the discordbot, change your directory to discord bot: cd discordbot/" echo "Do the same thing with run.py in the discordbot folder"
echo "and type the following command: python3.5 run.py" echo "The console will show: wsgi starting up on http://0.0.0.0:8080. Click on that url and hit Open to view the local webapp."
echo "------------------------------" echo "------------------------------"