gluon-config-api: use config-mode uhttpd instance
As of now, we prefer to use the existing uhttpd instance from the config-mode instead of creating our own.
This commit is contained in:
		
							parent
							
								
									493fe33eff
								
							
						
					
					
						commit
						299d6b8aa7
					
				@ -10,7 +10,7 @@ include ../gluon.mk
 | 
			
		||||
 | 
			
		||||
define Package/gluon-config-api
 | 
			
		||||
  TITLE:=Provides a REST API to configure the gluon node
 | 
			
		||||
  DEPENDS:=+gluon-web +uhttpd +libucl
 | 
			
		||||
  DEPENDS:=+gluon-web +uhttpd +libucl +gluon-config-mode-core
 | 
			
		||||
endef
 | 
			
		||||
 | 
			
		||||
$(eval $(call BuildPackageGluon,gluon-config-api))
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ local os = require 'os'
 | 
			
		||||
local glob = require 'posix.glob'
 | 
			
		||||
local libgen = require 'posix.libgen'
 | 
			
		||||
local simpleuci = require 'simple-uci'
 | 
			
		||||
local schema = dofile('../controller/schema.lua') -- pwd is www/
 | 
			
		||||
local schema = dofile('/lib/gluon/config-api/controller/schema.lua')
 | 
			
		||||
local ucl = require "ucl"
 | 
			
		||||
 | 
			
		||||
package 'gluon-config-api'
 | 
			
		||||
 | 
			
		||||
@ -1,36 +0,0 @@
 | 
			
		||||
#!/usr/bin/lua
 | 
			
		||||
 | 
			
		||||
local uci = require('simple-uci').cursor()
 | 
			
		||||
local site = require 'gluon.site'
 | 
			
		||||
 | 
			
		||||
local function get_mem_total()
 | 
			
		||||
	for line in io.lines('/proc/meminfo') do
 | 
			
		||||
		local match = line:match('^MemTotal:%s+(%d+)')
 | 
			
		||||
		if match then
 | 
			
		||||
			return tonumber(match)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local max_requests = 32
 | 
			
		||||
if get_mem_total() < 48*1024 then
 | 
			
		||||
	max_requests = 16
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
uci:section('uhttpd', 'uhttpd', 'config_api', {
 | 
			
		||||
	listen_http = { '0.0.0.0:83', '[::]:83' },
 | 
			
		||||
	listen_https = {},
 | 
			
		||||
 | 
			
		||||
	home = '/lib/gluon/config-api/www',
 | 
			
		||||
	max_requests = max_requests,
 | 
			
		||||
	max_connections = 100,
 | 
			
		||||
	redirect_https = true,
 | 
			
		||||
	rfc1918_filter = true,
 | 
			
		||||
	cgi_prefix = '/cgi-bin',
 | 
			
		||||
	script_timeout = 60,
 | 
			
		||||
	network_timeout = 30,
 | 
			
		||||
	http_keepalive = 20,
 | 
			
		||||
	tcp_keepalive = true,
 | 
			
		||||
})
 | 
			
		||||
uci:save('uhttpd')
 | 
			
		||||
uci:save('firewall')
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user