liquid_feedback_frontend
changeset 1163:ee63ad6bb3e3
merge
author | jbe |
---|---|
date | Tue Mar 24 12:55:22 2015 +0100 (2015-03-24) |
parents | a2922edacce0 385a1e369faf |
children | c43fdf63fee0 93b32111526f |
files |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/_prefork/10_init.lua Tue Mar 24 12:55:22 2015 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +if not config.fork then 1.5 + config.fork = {} 1.6 +end 1.7 + 1.8 +if not config.fork.pre then 1.9 + config.fork.pre = 4 1.10 +end 1.11 + 1.12 +if not config.fork.max then 1.13 + config.fork.max = 8 1.14 +end 1.15 + 1.16 +if not config.fork.delay then 1.17 + config.fork.delay = 1 1.18 +end 1.19 + 1.20 +if not config.port then 1.21 + config.port = 8080 1.22 +end 1.23 + 1.24 +if config.localhost == nil then 1.25 + config.localhost = true 1.26 +end 1.27 + 1.28 +listen{ 1.29 + { proto = "tcp4", port = config.port, localhost = true }, 1.30 + { proto = "interval", delay = 5, handler = function() 1.31 + Event:send_pending_notifications() 1.32 + end }, 1.33 + pre_fork = config.fork.pre, 1.34 + max_fork = config.fork.max, 1.35 + fork_delay = config.fork.delay 1.36 +} 1.37 + 1.38 +execute.inner() 1.39 +
2.1 --- a/config/devel.lua Tue Mar 24 12:55:01 2015 +0100 2.2 +++ b/config/devel.lua Tue Mar 24 12:55:22 2015 +0100 2.3 @@ -271,6 +271,9 @@ 2.4 2.5 config.enable_debug_trace = true 2.6 2.7 +config.fork = { pre = 64, max = 256, delay = 0.01 } 2.8 + 2.9 + 2.10 -- WebMCP accelerator 2.11 -- uncomment the following two lines to use C implementations of chosen 2.12 -- functions and to disable garbage collection during the request, to
3.1 --- a/config/init.lua Tue Mar 24 12:55:01 2015 +0100 3.2 +++ b/config/init.lua Tue Mar 24 12:55:22 2015 +0100 3.3 @@ -72,6 +72,13 @@ 3.4 -- compatibility for WebMCP 1.2.6 3.5 if not listen then 3.6 3.7 + WEBMCP_BASE_PATH = request.get_app_basepath() 3.8 + 3.9 + -- workaround bug in WebMCP 1.2.6 3.10 + if not string.find(WEBMCP_BASE_PATH, "/$") then 3.11 + WEBMCP_BASE_PATH = WEBMCP_BASE_PATH .. "/" 3.12 + end 3.13 + 3.14 -- open and set default database handle 3.15 _G.db = assert(mondelefant.connect(config.database)) 3.16 3.17 @@ -108,32 +115,4 @@ 3.18 request.add_header("Cache-Control", "max-age=3600"); 3.19 end 3.20 3.21 - return 3.22 -end 3.23 - 3.24 -if not config.fork then 3.25 - config.fork = {} 3.26 -end 3.27 - 3.28 -if not config.fork.pre then 3.29 - config.fork.pre = 4 3.30 -end 3.31 - 3.32 -if not config.fork.max then 3.33 - config.fork.max = 8 3.34 -end 3.35 - 3.36 -if not config.fork.delay then 3.37 - config.fork.delay = 1 3.38 -end 3.39 - 3.40 -if not config.port then 3.41 - config.port = 8080 3.42 -end 3.43 - 3.44 -listen{ 3.45 - { proto = "tcp4", port = config.port, localhost = true }, 3.46 - pre_fork = config.fork.pre, 3.47 - max_fork = config.fork.max, 3.48 - fork_delay = config.fork.delay 3.49 -} 3.50 +end 3.51 \ No newline at end of file
4.1 --- a/model/event.lua Tue Mar 24 12:55:01 2015 +0100 4.2 +++ b/model/event.lua Tue Mar 24 12:55:22 2015 +0100 4.3 @@ -59,8 +59,7 @@ 4.4 :add_where("event_seen_by_member.member_id ISNULL OR event_seen_by_member.member_id != member.id") 4.5 :exec() 4.6 4.7 - print (_("Event #{id} -> #{num} members", { id = self.id, num = #members_to_notify })) 4.8 - 4.9 + io.stderr:write("Sending notifications for event " .. self.id .. " to " .. (#members_to_notify) .. " members\n") 4.10 4.11 local url 4.12 4.13 @@ -167,19 +166,31 @@ 4.14 4.15 event:send_notification() 4.16 4.17 + if config.notification_handler_func then 4.18 + config.notification_handler_func(event) 4.19 + end 4.20 + 4.21 return true 4.22 4.23 end 4.24 4.25 end 4.26 4.27 +function Event:send_pending_notifications() 4.28 + while true do 4.29 + if not Event:send_next_notification() then 4.30 + break 4.31 + end 4.32 + end 4.33 +end 4.34 + 4.35 function Event:send_notifications_loop() 4.36 4.37 while true do 4.38 local did_work = Event:send_next_notification() 4.39 if not did_work then 4.40 - print "Sleeping 1 second" 4.41 - os.execute("sleep 1") 4.42 + print "Sleeping 5 second" 4.43 + os.execute("sleep 5") 4.44 end 4.45 end 4.46