sethtroisi / cloudygo

Website for MiniGo, Leela-Zero and other Go data
http://cloudygo.com
Apache License 2.0
20 stars 10 forks source link

/puzzles/ fails in production #31

Closed sethtroisi closed 5 years ago

sethtroisi commented 5 years ago

https://cloudygo.com/v14-19x19/puzzles/ is failing. https://cloudygo.com/v14-19x19/puzzles/1 and https://cloudygo.com/v14-19x19/puzzles/2 work http://localhost:5002/v14-19x19/puzzles/ also works.

sethtroisi commented 5 years ago

Debug and root was fun so I thought I'd write it down.

  1. The zeroth sgf is move 235 from "-Nieweiping28203.sgf" Really fast readers very familiar with this domain might already guess my problem. It took me much longer.
  2. The problem is in this try catch so there isn't errors.
    • I test a couple of things locally and everything looks good
    • In production (apache + mod_wsgi + flask) it dies in the block
    • printf debug show the read fails.
      • I spend five minutes verifying permissions for apache in the sgf directory
    • I finally log the exception [remote 127.0.0.1:35974] 'ascii' codec can't decode byte 0xe4 in position 54: ordinal not in range(128)
      • I read the file PB[丁 伟], this is why the name starts with a "-"
  3. open(..).read() works if I add encoding="utf-8"
    • In prod locale.getpreferredencoding(False) => ANSI_X3.4-1968
    • locally locale.getpreferredencoding(False) => UTF-8

The fix is to specify lang=en_US.UTF-8 to WSGIDaemonProcess in my apach2 config