Installation Guide - SSD2015/TeamGG GitHub Wiki
The server application requires MariaDB. JDK8 is recommended, but 7 also can be used. The server is only tested on OS X and Linux.
- Make sure that you have MariaDB and JDK installed.
- Create a database for the application, and a database user able to modify schema and data:
$ mysql -u root -p
MariaDB [<none>]> CREATE DATABASE exceedvote;
MariaDB [<none>]> CREATE USER 'exceedadmin'@'localhost' IDENTIFIED BY 'adminExceed';
MariaDB [<none>]> GRANT ALL On exceedvote.* to 'exceedadmin'@'localhost';
MariaDB [<none>]> flush privileges;
MariaDB [<none>]> quit;
- Configure database settings in the file
conf/application.conf
. Set the following:
db.default.url="jdbc:mysql://localhost/exceedvote"
db.default.user="exceedadmin"
db.default.password="adminExceed"
- Start a development server by entering
./activator run
on a command line. - Required dependencies are downloaded automatically. The first time this is run it will take around 10 minutes, depending on your Internet connection speed.
- The development server will be available at
http://localhost:9000
. The first time you access this URL, a database migration (called an "evolution") is required. Click the "Apply this script now!" button to apply the evolution. When it finishes, the normal ExceedVote home page is displayed.
- Make sure that node.js is installed in addition to MariaDB
- Create a database for the application using the step outlined above
- Generate application secret by running
./activator play-generate-secret
. You'll get an application secret similar to this one:dK[JS5v0ASPkFWrM8mL0sC;tFl>O0ND_X1gsj:l^KKL=2cf9M=e5WHMyQZlS_p@
- Write your application secret and database settings to a new file,
conf/production.conf
include "application"
application.secret="dK[JS5v0ASPkFWrM8mL0sC;tFl>O0ND_X1gsj:l^KKL=2cf9M=e5WHMyQZlS_p@"
db.default.url="jdbc:mysql://localhost/exceedvote?user=username&password=...."
- Compile the application in production mode
export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node"
./activator clean stage
- Run the application (note: this command should be put into autostart system like cron's
@reboot
, initscript or supervisord)
./target/universal/stage/bin/exceedvote -Dconfig.file=/full/path/to/conf/production.conf -Dhttp.port=4646 -Dhttp.host=0.0.0.0 -DapplyEvolutions.default=true
(note: substitute your full path to configuration file, and change the port if necessary)
- You can config a reverse proxy (like nginx or varnish) to the application's port.
When the application is started the first time there is no users created. We can create new users from the administrative console but we need to create a user who can access it first.
To create a new user, run the following SQL command
INSERT INTO user (username, type) VALUES ("b5610545757", 2);
You then can access the new account using your Kasetsart credentials for that username.
(This code added in a branch.) ExceedVote can automatically add an administrative user to a fresh install. It only does this when:
- the
User
table of the database is empty. - a username and password are set in
conf/application.conf
using the following variables:
exceed.admin.username="admin"
exceed.admin.password="changeThisPassword"
In the above, you can use any username and password you like; the username may contain only alphanumeric chars.
This will enable you to login to ExceedVote. Once logged in, you should change the admin user's password from within ExceedVote, and set the username/password in conf/application.conf
to empty strings (to discourage hackers).
To run the unit tests, make sure that there is a database exceedvote_test
which is accessible by user root
without password. Also, phantomjs
must be installed. Execute ./activator test
to start testing.
Some tests are skipped when a valid KU account is not configured. To run them, setup a valid KU account with test.kuuser=...
and test.kupassword=...
in conf/application.conf
.
The clientside application is written using Ionic framework. However, it is not required to run it in some cases. It is located at TeamGG-mobile.
You can run the client by putting the www
folder onto a web server. Ionic provides a function to run a simple HTTP server by running ionic serve
. A browse window will automatically open.
To run the application on Android, Ionic is required. Type the following commands while a phone is connected in debug mode:
ionic platform add android
ionic run
The first command is only required on the first time checking out the repository.
To build an APK (provided that you have run ionic platform add android
):
ionic build --release
if the build succeeded, a path to APK will be displayed.
By default, the mobile application will connects to the server at a hardcoded endpoint at https://gg.whs.in.th/api/
. You can change to your server by changing it in www/js/controllers.js
line 2.