Skip to content

Commit

Permalink
docker: luarocks, luaflock, lua-sql-sqlite3
Browse files Browse the repository at this point in the history
Some useful packages that a user might want available to their
Lua scripts:

- `luaflock`: BSD-style flock
- `lua-sql-sqlite3`: SQLite bindings for Lua

Also print the lua error code and error message string in the error
handler. It seems like not all Lua errors have stack traces/tracebacks,
e.g. requiring a non-existent module:

before:

```
lua runtime error:
terminate called after throwing an instance of 'OsmLuaProcessing::luaProcessingException'
  what():  std::exception
```

after:

```
lua runtime error 2:
./file_append.lua:7: module 'flock' not found:
	no field package.preload['flock']
	no file './flock.lua'
	no file '/usr/local/share/lua/5.1/flock.lua'
	no file '/usr/local/share/lua/5.1/flock/init.lua'
	no file '/usr/local/lib/lua/5.1/flock.lua'
	no file '/usr/local/lib/lua/5.1/flock/init.lua'
	no file '/usr/share/lua/5.1/flock.lua'
	no file '/usr/share/lua/5.1/flock/init.lua'
	no file './flock.so'
	no file '/usr/local/lib/lua/5.1/flock.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1/flock.so'
	no file '/usr/lib/lua/5.1/flock.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
terminate called after throwing an instance of 'OsmLuaProcessing::luaProcessingException'
  what():  std::exception
```
  • Loading branch information
cldellow committed Oct 3, 2024
1 parent a196c9d commit a2081eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
libboost-iostreams-dev \
rapidjson-dev \
cmake \
luarocks \
lua-sql-sqlite3 \
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \
luarocks install luaflock

WORKDIR /usr/src/app

Expand Down
3 changes: 2 additions & 1 deletion src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ bool supportsRemappingShapefiles = false;

int lua_error_handler(int errCode, const char *errMessage)
{
std::cerr << "lua runtime error: " << std::endl;
std::cerr << "lua runtime error " << std::to_string(errCode) << ":" << std::endl;
std::cerr << errMessage << std::endl;
kaguya::util::traceBack(g_luaState->state(), errMessage); // full traceback on 5.2+
kaguya::util::stackDump(g_luaState->state());
throw OsmLuaProcessing::luaProcessingException();
Expand Down

0 comments on commit a2081eb

Please sign in to comment.