Compare commits
7 Commits
d29dff57c4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b6627d3cd3 | |||
| bc3256cc4c | |||
| 2d97f02929 | |||
| a6b8cf31fe | |||
| 9da52baabb | |||
| 41f8f8f815 | |||
| a8bb1a648e |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
!/src
|
||||
!/lib
|
||||
/!decl
|
||||
!/decl
|
||||
!/deps
|
||||
|
||||
!/.editorconfig
|
||||
!/.gitignore
|
||||
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "deps/mklua"]
|
||||
path = deps/mklua
|
||||
url = https://git.topcheto.eu/topchetoeu/mklua.git
|
||||
21
Dockerfile
21
Dockerfile
@@ -1,36 +1,31 @@
|
||||
FROM alpine AS build
|
||||
|
||||
RUN apk add --no-cache lua5.4-dev lua5.4-luv make gcc pkgconf util-linux-misc
|
||||
RUN apk add --no-cache lua5.4-dev lua5.4-luv build-base pkgconf util-linux-misc
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY src ./src/
|
||||
COPY lib ./lib/
|
||||
COPY Makefile ./Makefile
|
||||
COPY mklua ./mklua
|
||||
# ADD https://git.topcheto.eu/topchetoeu/mklua/releases/download/latest/mklua ./mklua
|
||||
COPY deps ./deps
|
||||
|
||||
RUN ln -s /usr/lib/liblua-5.4.so.0 /usr/lib/liblua.so.5.4
|
||||
RUN ./mklua
|
||||
RUN make MKLUA=./mklua
|
||||
# ADD https://git.topcheto.eu/topchetoeu/mklua/releases/download/latest/mklua ./mklua
|
||||
RUN make LUA=lua5.4
|
||||
|
||||
FROM alpine
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
VOLUME /plugins
|
||||
VOLUME /views
|
||||
VOLUME /static
|
||||
VOLUME /config
|
||||
VOLUME /data
|
||||
|
||||
STOPSIGNAL SIGINT
|
||||
|
||||
HEALTHCHECK --interval=30s --start-period=1s CMD curl localhost:8080/.well-known/keepalive | grep "OK"
|
||||
ENTRYPOINT ./bin/website
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /
|
||||
|
||||
RUN apk add --no-cache lua5.4 lua5.4-luv
|
||||
|
||||
COPY --from=build ./bin/website .
|
||||
COPY --from=build /build/bin/website .
|
||||
|
||||
CMD [ "./website", "./data/config.lua" ]
|
||||
|
||||
12
Makefile
12
Makefile
@@ -1,5 +1,5 @@
|
||||
# Generated by mklua
|
||||
MKLUA ?= mklua
|
||||
MKLUA ?= ./deps/mklua/mklua
|
||||
CC ?= cc
|
||||
OUTPUT ?= website
|
||||
|
||||
@@ -36,15 +36,21 @@ all: $(OUTPUT)
|
||||
|
||||
clean:
|
||||
rm -fr $(BINDIR) $(MKLUA_OUT) deps/luv
|
||||
rm -fr deps/mklua
|
||||
|
||||
compile_flags.txt:
|
||||
printf -- '$(foreach v,$(CCARGS) $(LDARGS),\n$v)' > compile_flags.txt
|
||||
|
||||
$(OUTPUT): $(LIBS) $(MKLUA_OUT) $(SOURCES) | $(dir $(OUTPUT))
|
||||
$(CC) $(CCARGS) $(LDARGS) $^ -o $@
|
||||
$(CC) $(CCARGS) $^ $(LDARGS) -o $@
|
||||
|
||||
$(MKLUA_OUT): $(DEPS) | $(dir $(MKLUA_OUT))
|
||||
$(MKLUA_OUT): $(DEPS) | $(dir $(MKLUA_OUT)) $(MKLUA)
|
||||
$(MKLUA) $(MKLUA_FLAGS) $(MKLUA_ENTRY) -o $@
|
||||
|
||||
deps/mklua/Makefile:
|
||||
git submodule update --init deps/mklua
|
||||
|
||||
$(MKLUA): deps/mklua/Makefile
|
||||
make -C deps/mklua
|
||||
%/:
|
||||
mkdir -p $@
|
||||
|
||||
4090
decl/luv.d.lua
Normal file
4090
decl/luv.d.lua
Normal file
File diff suppressed because it is too large
Load Diff
1
deps/mklua
vendored
Submodule
1
deps/mklua
vendored
Submodule
Submodule deps/mklua added at 5f343c2126
@@ -270,7 +270,7 @@ local function http_read_req(stream)
|
||||
|
||||
local type, path, version = line:match "^(%S-) (%S-) HTTP/(%S-)\r\n$";
|
||||
if not type then return nil, "unexpected format" end
|
||||
if version ~= "1.1" then return nil, "only HTTP 1.1 supported" end
|
||||
if version ~= "1.1" and version ~= "1.0" then return nil, "only HTTP 1.1/1.0 supported, got " .. version end
|
||||
|
||||
local headers, err = http_read_headers(stream);
|
||||
if not headers then return nil, err end
|
||||
@@ -288,7 +288,7 @@ local function http_read_res(stream)
|
||||
|
||||
local version, code = line:match "^HTTP/(%S-) (%S-) (.-)\r\n$";
|
||||
if not version then return nil, "unexpected format" end
|
||||
if version ~= "1.1" then return nil, "only HTTP 1.1 supported" end
|
||||
if version ~= "1.1" and version ~= "1.0" then return nil, "only HTTP 1.1/1.0 supported, got " .. version end
|
||||
|
||||
local headers, err = http_read_headers(stream);
|
||||
if not headers then return nil, err end
|
||||
|
||||
12
src/sync/sig.lua
Normal file
12
src/sync/sig.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
--- @param sig uv.aliases.signals
|
||||
--- @param cb fun(num: uv.aliases.signals): false?
|
||||
return function (sig, cb)
|
||||
local self = assert(uv.new_signal());
|
||||
|
||||
uv.signal_start(self, sig, function (num)
|
||||
if cb(num) == false then
|
||||
uv.signal_stop(self);
|
||||
uv.close(self);
|
||||
end
|
||||
end);
|
||||
end
|
||||
@@ -2,6 +2,7 @@ require "utils.printing";
|
||||
require "template";
|
||||
require "plugin.breadcrumbs";
|
||||
require "plugin.navbar";
|
||||
local sig = require "sync.sig"
|
||||
|
||||
local sync = require "sync";
|
||||
local tcp = require "sync.tcp";
|
||||
@@ -30,8 +31,18 @@ end
|
||||
|
||||
return require "sync.entry" (function (...)
|
||||
-- Why a bad pipe manages to topple a whole process in unix is beyond me
|
||||
local sigpipe = assert(uv.new_signal());
|
||||
uv.signal_start(sigpipe, "sigpipe", function () end);
|
||||
sig("sigpipe", function (num) end);
|
||||
sig("sigint", function (num)
|
||||
print "Gracefully exiting...";
|
||||
uv.stop();
|
||||
|
||||
sig("sigint", function (num)
|
||||
print "SIGINT repeated, forcefully exiting...";
|
||||
os.exit(0);
|
||||
end);
|
||||
|
||||
return false;
|
||||
end);
|
||||
|
||||
local conf_file = ...;
|
||||
local config = assert(loadfile(conf_file))();
|
||||
|
||||
Reference in New Issue
Block a user