J-ogawa / isucon_dev

isucon本番の開発用ブランチ
0 stars 0 forks source link

アプリ <-> mysql をドメインソケットでつなぐ #9

Open J-ogawa opened 7 years ago

J-ogawa commented 7 years ago

Mysql2::Clientの場合はhost,port指定の代わりにsocket指定

def db
        Thread.current[:isu4_db] ||= Mysql2::Client.new(
          socket: ENV['ISU4_DB_SOCKET'] || '/tmp/mysql.sock',
          username: ENV['ISU4_DB_USER'] || 'root',
          password: ENV['ISU4_DB_PASSWORD'],
          database: ENV['ISU4_DB_NAME'] || 'isu4_qualifier',
          reconnect: true,
        )
end