taiko-web development has returned to GitHub. This Gitea instance will be shut down soon.
If your taiko-web fork is unavailable due to DMCA takedown, you can contact GitHub Support and ask for it to be deleted.
Setup
Bui edited this page 7 months ago

Requirements

To set up and configure taiko-web, you’ll need a few things:

  • A Linux server with the following software installed:
    • git
    • SQLite
    • Python 2.7
    • Python 3.5 (or later)
    • ffmpeg (or libav/avconv)
      • Must be compiled with libmp3lame codec
    • nginx
  • Songs. taiko-web supports TJA and OSU notecharts.
    • If using TJA charts, you’ll need software to convert your OGG audio files to MP3.

While it’s possible to set up taiko-web under a different environment (eg. using a Windows server, or using a different web server than nginx), this guide uses the method tested by the taiko-web developers that is known to work.

Setup

Installing the requirements

If you have not already done so, install the above-listed software on your server. The following commands were ran on a Debian 9 system, you may need to alter them depending on your OS.

sudo apt update
sudo apt install git sqlite3 python2.7 python-virtualenv python3.5 python3-virtualenv ffmpeg nginx

Obtaining taiko-web

Next, clone the taiko-web repository into a directory of your choosing.

sudo mkdir -p /srv/taiko-web
sudo chown $USER /srv/taiko-web
git clone https://git.taiko.zone/bui/taiko-web.git /srv/taiko-web

All the commands you run from now on must be ran inside the taiko-web directory, so change your working directory.

cd /srv/taiko-web

nginx setup

Let’s set up nginx now. Create a new virtual host file, eg. /etc/nginx/conf.d/taiko-web.conf and use this example configuration, changing the server_name and root statements as required.

server {
    listen 80;
    server_name taiko.example.com;
    server_tokens off;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $server_name;
        proxy_read_timeout 7200s;
        proxy_pass http://127.0.0.1:34801;
        proxy_max_temp_file_size 50000m;
    }

    location ~ ^/(assets|songs|src)/ {
        root   /srv/taiko-web/public;
        location ~ ^/songs/([0-9]+)/preview\.mp3$ {
            try_files $uri /api/preview?id=$1;
        }
    }

    location /p2 {
        proxy_pass http://127.0.0.1:34802;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}

Once you’ve saved your file, reload nginx. You shouldn’t get any errors.

sudo nginx -s reload

If you try to access your simulator now, you should get a 502 error. That’s because we haven’t started the app server yet, so let’s do that!

taiko-web setup

We’ll first create virtual environments for both of our Python versions and install the required modules for each.

virtualenv -p /usr/bin/python2 .venv2
source .venv2/bin/activate
pip install Flask ffmpy gunicorn
deactivate

virtualenv -p /usr/bin/python3 .venv3
source .venv3/bin/activate
pip install websockets
deactivate

It is recommended that you use a process manager such as Supervisor to keep taiko-web running at all times. Installing it is easy:

sudo apt install supervisor

Make a new config file at /etc/supervisor/conf.d/taiko-web.conf with the following contents, adjusting it as needed:

[program:taiko_web]
directory=/srv/taiko-web
command=/srv/taiko-web/.venv2/bin/gunicorn -b 127.0.0.1:34801 app:app
autostart=true
autorestart=true

[program:taiko_multiplayer]
directory=/srv/taiko-web
command=/srv/taiko-web/.venv3/bin/python server.py 34802
autostart=true
autorestart=true

Then, restart Supervisor.

sudo service supervisor restart

We’re almost there! taiko-web has been installed, but you’ll get an error on trying to load it because there’s no song database yet. Let’s fix that!

Database setup

Open the SQLite shell by running sqlite3 and execute the following queries to set up the tables you’ll need:

.open taiko.db
CREATE TABLE "categories" ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `title` TEXT NOT NULL );
INSERT INTO categories VALUES(1,'J-POP');
INSERT INTO categories VALUES(2,'アニメ');
INSERT INTO categories VALUES(3,'ボーカロイド™曲');
INSERT INTO categories VALUES(4,'バラエティ');
INSERT INTO categories VALUES(5,'クラシック');
INSERT INTO categories VALUES(6,'ゲームミュージック');
INSERT INTO categories VALUES(7,'ナムコオリジナル');
CREATE TABLE "song_skins" ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `song` TEXT, `stage` TEXT, `don` TEXT );
CREATE TABLE "songs" ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `title` TEXT NOT NULL, `title_lang` TEXT, `subtitle` TEXT, `subtitle_lang` TEXT, `easy` INTEGER, `normal` INTEGER, `hard` INTEGER, `oni` INTEGER, `ura` INTEGER, `enabled` INTEGER NOT NULL, `category` INTEGER, `type` TEXT, `offset` REAL, `skin_id` INTEGER );

So we have the song genres, but still no songs. In this example we’re going to add Saitama 2000. We’d execute a query like this:

INSERT INTO songs VALUES(1,'さいたま2000','en Saitama 2000
cn 埼玉2000
tw 埼玉2000
ko 사이타마 2000',NULL,NULL,5,7,7,7,NULL,1,7,'tja',-0.015,NULL);

Once you have inserted your song, exit SQLite with .exit to return to your shell.

The song is in the database, now let’s actually add the files for it. In taiko-web, each song has a folder under public/songs/ corresponding to its ID in the database. There isn’t a songs folder by default, so make one:

mkdir -p public/songs
mkdir -p public/songs/1

Then, move main.tja and main.mp3 into the newly-created directory. For the sake of this example, you can download the files from my taiko-web instance.

wget -O public/songs/1/main.tja https://ro.765.cx/songs/3/main.tja
wget -O public/songs/1/main.mp3 https://ro.765.cx/songs/3/main.mp3

Finishing up

And… that’s it! Assuming you did everything correctly, you should now be able to access your simulator and play the song you just added.

If any part of this guide wasn’t clear, please ask Bui on the Taiko no Tatsujin Discord for clarification so the guide can be updated accordingly.

Happy drumming!