Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

TicTrainer and TicTimer Web

This project contains the files used to serve TicTrainer™ via node.js. TicTrainer™ is a web tool meant to help people build their ability to fight their tics. It was built to implement the RE-ERP strategy proposed by Kevin Black (see description here).

Also included now is TicTimer Web, which runs on the same server and is accessed at webroot/tsp/. TicTimer is a program designed to automate record keeping and reward delivery during tic suppression research. This web-based version of TicTimer allows for sessions to be performed remotely and without the bulky token dispenser hardware that was used with the previous version of TicTimer. See description here.

Download and Installation

  1. Download this git repository to the server
    1. $ git clone --depth 1 -b master
    2. alternatively, download and scp those files
  2. Install mysql 8.0 Guide
  3. Install node.js 12 Guide Better? Guide
    1. Run $ npm install From the /src folder to install dependencies from package.json


  1. Set up mysql database
    1. If restoring from a backup, do that and skip the following. Backup/Restore Guide
    2. Start the mysql database if not already running $ mysqld
    3. Log in as root $ mysql -u root -p
    4. Create the nodejs user and the tictrainer database as described in Project_Files/sql/setup.sql
      1. Can copy and paste everything except the password
    5. Execute the other .sql files in that folder. Order matters Guide
      1. Create accounts tables (admins.sql, trainers.sql, users.sql)
      2. Create links table (links.sql)
      3. Create survey_state table (survey_state.sql)
      4. Create session index table (sessions.sql)
  2. Add the keys.json file to the parent directory of the git repository
	"sql": "[mysql_password]",
	"ckses": "[cookie_key]"
  1. Alter settings if needed (src/settings.json)
    1. A clear description of each of the settings is in the file src/settings_description.txt
    2. The constant "testing" should be set as false for the server to use the normal ports (80 and 443). Otherwise, it will run on port 8888.
    3. Be sure to keep the proper formatting of the json file.
  2. Hosting-specific things (This is not generalizable, but this is how we did it)
    1. Open ports 80 and 443 in the firewall settings
    2. Set up certbot for Let's Encrypt. Guide here, but don't follow whole thing
      1. $ yum install epel-release
      2. $ yum install certbot
    3. Get certificate from Let's Encrypt.
      1. sudo certbot certonly --force-renewal -d -d --standalone --cert-name --preferred-challenges http
      2. Port 80 needs to be free (i.e. don't have the server running)
      3. The domain name needs to be set up to redirect to the server.
    4. Create crontab jobs
      1. Let's Encrypt auto-renewing certificate: $ sudo crontab -e
        1. 32 04 3 1,3,5,7,9,11 * /home/ec2-user/TicTrainer-node/util_scripts/
        2. This auto-renews the certificate every odd month. On the inside, this script runs the same command from 4.iii.a
      2. FreeDNS update IP: $ crontab -e
        1. If your server IP address is changing unpredictably: 3,8,13,18,23,28,33,38,43,48,53,58 * * * * sleep 22 ; curl -s >> /tmp/freedns_tictrainer_mooo_com.log 2>/dev/null
        2. If your server IP address is more stable: 21 2,14 * * * sleep 17; curl -s >> /tmp/freedns_tictrainer_mooo_com.log 2>/dev/null

Running the server

Run the script /util_scripts/ (making sure that the pathnames are correct there)


  1. cd to the "/src" directory.
  2. path/to/Tt_repository/src$ sudo nohup node server.js &> logs/log.txt &
    1. "sudo" because it needs to be run as root to use ports 80 and 443
    2. "nohup" lets the server continue running after closing the ssh session
    3. "&>" pipes output to log.txt