我使用 lapis 框架和 torch,有时网站在尝试加载页面时显示内部服务器错误,而来自 lapis 的错误是:
[error] 3726#81246: *19 lua entry thread aborted: runtime error: ...s/MyUser/torch/install/share/lua/5.1/xlua/init.lua:227: bad argument #2 to 'tonumber' (number expected, got string)
stack traceback:
coroutine 0:
[C]: in function 'require'
.../MyUser/torch/install/share/lua/5.1/lapis/init.lua:15: in function 'serve'
content_by_lua(nginx.conf.compiled:22):2: in function <content_by_lua(nginx.conf.compiled:22):1>, client: 127.0.0.1, server: , request: "GET /recommend HTTP/1.1", host: "localhost:9999", referrer: "http://localhost:9999/home"
环顾四周后,当我评论这部分时,问题就消失了:
local lapis = require("lapis")
local config = require("lapis.config").get()
local inspect = require("inspect")
local json = require('cjson')
local kb_recommend = require("recommender.knowledge")
-- local cb_recommend = require("recommender.content") <---- remark this
local mysql = require "luasql.mysql"
local env = mysql.mysql()
local conn = env:connect("restoran", "root", "")
那是文件推荐器/content.lua 的链接:
package.path = package.path .. ";../?.lua"
local predictor = require("Content Based.predictor")
return predictor
该文件返回我编写Torch代码的类。我怀疑问题出在“要求”部分,但不知道为什么?我一直在谷歌上寻找解决方案,但没有找到。这是我当前的版本:
Lua 5.1.5
Torch7
Lapis 1.6.0
nginx/1.13.9
openresty/1.13.6.1
有人可以帮忙吗?我是 Lua 环境中的新手。