93 lines
2.2 KiB
Lua
Executable File
93 lines
2.2 KiB
Lua
Executable File
#!/usr/bin/env lua
|
|
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
|
|
-- LADI Continuous Integration (ladici)
|
|
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
|
|
-- SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
local protocols = require 'protocols'
|
|
--local hub = require 'hub'
|
|
local remotes = require 'remotes'
|
|
local locations = require 'locations'
|
|
local irc_client = require 'irc_client'
|
|
local irc_server = require 'irc_server'
|
|
local http_server = require 'http_server'
|
|
local misc = require 'misc'
|
|
|
|
local homedir = os.getenv('HOME')
|
|
if not homedir then
|
|
print("HOME env var not set")
|
|
os.exit(1)
|
|
end
|
|
|
|
-- Have one config file per user, one for the runner and one per worker
|
|
success, config = pcall(dofile, homedir .. '/.ladici')
|
|
if not success then
|
|
print("Warning: " .. err)
|
|
--else
|
|
-- print("config:")
|
|
-- misc.dump_table(config)
|
|
end
|
|
|
|
-- misc.dump_table(protocols)
|
|
-- misc.dump_table(remotes)
|
|
-- misc.dump_table(locations)
|
|
-- misc.dump_table(irc_client)
|
|
-- misc.dump_table(irc_server)
|
|
|
|
protocols.register(irc_client)
|
|
|
|
-- locations.register('localhost',
|
|
-- 'IRC',
|
|
-- {host='localhost', nick='ladici', realname='Operator Real Name', join='#ladi'})
|
|
|
|
local router = function(request)
|
|
print(request.verb .. " " .. request.path .. " " .. request.proto)
|
|
misc.dump_table(request.headers)
|
|
|
|
local response = {}
|
|
response.status = 200
|
|
response.headers = {}
|
|
response.headers["Server"] = "ladici"
|
|
response.headers["Connection"] = "close"
|
|
response.headers["Content-Type"] = "text/html"
|
|
response.body = "<!DOCTYPE html>\
|
|
<head>\
|
|
<title>LADI Continuous Integration</title>\
|
|
</head>\
|
|
<body>\
|
|
LADI Continuous Integration\
|
|
<br>\
|
|
WIP\
|
|
<br>\
|
|
yeah!\
|
|
</body>\
|
|
"
|
|
return response
|
|
end
|
|
|
|
-- the defaults
|
|
settings = {}
|
|
settings.mode = 'hq'
|
|
settings.http_bind = "127.0.0.1"
|
|
settings.http_port = 8010
|
|
|
|
-- read site/node/machine settings from config table
|
|
if config then
|
|
for k, v in pairs(settings) do
|
|
-- print(k, v, config[k])
|
|
if config[k] then
|
|
settings[k] = config[k]
|
|
end
|
|
end
|
|
end
|
|
|
|
--print("settings:")
|
|
--misc.dump_table(settings)
|
|
|
|
err = http_server.create(router, settings.http_port, settings.http_bind)
|
|
if err then
|
|
print(err)
|
|
else
|
|
while remotes.dispatch() do end
|
|
end
|