Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Fixed

- Do not recreate server if it's address and port were not changed (#219).

## [1.8.0] - 2025-07-07

The release introduces a new log level configuration option in `httpd` role
Expand Down
2 changes: 1 addition & 1 deletion roles/httpd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ local function apply_http(name, node)
httpd = httpd,
routes = {},
}
elseif servers[name].host ~= host or servers[name].port ~= port then
elseif servers[name].httpd.host ~= host or servers[name].httpd.port ~= port then
servers[name].httpd:stop()
servers[name].httpd = http_server.new(host, port, parse_params(node))
servers[name].httpd:start()
Expand Down
16 changes: 16 additions & 0 deletions test/integration/httpd_role_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ g.test_change_server_addr_on_the_run = function(cg)
t.assert_equals(resp.body, 'pong')
end

g.test_keep_existing_server_routes_on_config_reload = function(cg)
local resp = http_client:get('http://0.0.0.0:13001/ping_once')
t.assert_equals(resp.status, 200, 'response not 200')
t.assert_equals(resp.body, 'pong once')

local cfg = table.deepcopy(config)
cfg.credentials.users.testguest = { roles = {'super'} }
treegen.write_file(cg.server.chdir, 'config.yaml', yaml.encode(cfg))
local _, err = cg.server:eval("require('config'):reload()")
t.assert_not(err)

resp = http_client:get('http://0.0.0.0:13001/ping_once')
t.assert_equals(resp.status, 200, 'response not 200')
t.assert_equals(resp.body, 'pong once')
end

g.test_log_requests = function(cg)
t.skip_if(cg.params.use_tls)

Expand Down
10 changes: 10 additions & 0 deletions test/mocks/mock_role.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local M = {dependencies = { 'roles.httpd' }}

local servers = {}
local applied = {}

M.validate = function() end

Expand All @@ -14,6 +15,15 @@ M.apply = function(conf)
}, function(tx)
return tx:render({text = 'pong'})
end)

if applied[server.id] == nil then
servers[server.id]:route({
path = '/ping_once',
}, function(tx)
return tx:render({text = 'pong once'})
end)
applied[server.id] = {}
end
end
end
end
Expand Down
Loading