Web-based danmaku server
-
Get yourself a VPS
-
Clone this project
git clone https://github.com/tuna/gdanmaku-server cd gdanmaku-server
Pay attention to where you see this guide and what repository you are cloning from. Actual repository address may differ.
-
Install
openssl
curl
python3
nano
if there isn't -
Install
docker
anddocker-compose
if there isn'tsudo snap install docker sudo curl -L --fail https://github.com/docker/compose/releases/download/1.22.0/run.sh -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
We recommend you use docker pre-installed images from your VPS provider since there are many caveats when installing them yourself.
-
Edit configs to your preference
python3 -c "import random,hashlib;print(hashlib.sha1(str(random.random()).encode()).hexdigest())"
Copy the output, we will call it <SECRET> in the following easy steps.
curl -4 icanhazip.com
This should be your public ip, we will use it in the following steps.
If you want to use Wechat, log into your Wechat Subscription Account, get your
Token
.If you want to use telegram, get your telegram token. Now we can start editing configs
cd docker_conf nano settings_local.py
Copy the following contents into it.
DEBUG = False SECRET_KEY = "<SECRET>" # WECHAT WECHAT_TOKEN = "<WECHAT_TOKEN>" # TELEGRAM TELEGRAM_TOKEN = "<TELEGRAM_TOKEN>"
Change <SECRET>, <WECHAT_TOKEN>, <TELEGRAM_TOKEN> according to your situation.
After that you can press Ctrl + O to save and Ctrl + X to exit.
-
Run the script and open corresponding ports
chmod +x ./easy_setup.sh sudo ./easy_setup.sh
Wait until everything finished.
If you have trouble building docker image in executing the script above, you can try uncommenting the lines commented in PROJECT_ROOT_DIR/Dockerfile
Then open port
80
,443
in your VPS according to your OS and VPS provider.If you do not use telegram support, then it is okay to keep port
443
closed. -
Edit Wechat Subscription Account if necessary
Change
URL
in your account settings tohttp://<PUBLIC_IP>/api/wechat
-
Finished
Now you are all set, go to https://www.github.com/tuna/danmaQ and get a display client.
Install dependencies:
- python modules:
flask
,gevent
,pyredis
- service:
redis
Run webserver.py
and open http://localhost:5000/ in your browser.
Use this method only if you want to see what's under the hood. To actually host this server, please use docker instead.
You should have a vps first, then you need to install the docker if you do not have one.
You can find help in Prepare your Docker Environment or your VPS provider's knowledge base.
Clone this project
Pay attention to where you see this guide and what repository you are cloning from. Actual repository address may differ.
git clone https://github.com/tuna/gdanmaku-server
cd gdanmaku-server
Get a redis docker and run
docker pull redis:alpine
docker run --name redis -v /var/lib/redis:/data -d redis:alpine
Modify settings.py
in dir gdanmaku
, remember REDIS_HOST
in your settings i.e. myredis
.
If you want to use it in Wechat, please modify the
WECHAT_TOKEN
insetting.py
. ChangeTELEGRAM_TOKEN
as well if you want to utilize telegram bot.
Modify Dockerfile
, you may want to change the sources.list
part. Next we build the docker image of danmaku:
docker build --tag danmaku:dev .
We need to link redis to it. Try:
docker run -it --rm --link redis:myredis -p IP:Port:5000 danmaku:dev python3 gdanmaku/webserver.py
Open your browser and visit http://IP:port/, you should see the danmaku web page.
If you wanna run danmaku service as a daemon, use
docker run -d --name danmaku --link redis:myredis -v /path/to/gdanmaku-server:/data/gdanmaku -p IP:Port:5000 danmaku:dev python3 gdanmaku/webserver.py
If you want to use it in Wechat alone, please set port
to 80, and open the firewall.
If you want to use it in Telegram, however, you need to setup reverse proxy and a certificate besides set
port
to 5000.Here are the links for Telegram Webhook Setup Tutorial in your convenience. You may find
docker_conf/easy_setup.sh
anddocker_conf/nginx.conf
helpful.
Good luck, and have fun!
The official desktop client is available at https://github.com/tuna/danmaQ