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 17, 2024
1 parent 22ecab7 commit 40f366f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-system-dev \
luarocks \
rapidjson-dev \
cmake && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \
luarocks install luaflock

WORKDIR /usr/src/app

Expand All @@ -35,13 +37,15 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
liblua5.1-0 \
shapelib \
libsqlite3-0 \
lua-sql-sqlite3 \
libboost-filesystem1.74.0 \
libboost-program-options1.74.0 && \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app
COPY --from=src /usr/src/app/build/tilemaker .
COPY --from=src /usr/src/app/build/tilemaker-server .
COPY --from=src /usr/local/lib/lua/5.1/flock.so /usr/local/lib/lua/5.1/flock.so
COPY resources ./resources
COPY process.lua ./
COPY config.json ./
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 @@ -199,7 +199,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 40f366f

Please sign in to comment.