diff --git a/CronosAgent.c b/CronosAgent.c index 93619a2..459df33 100644 --- a/CronosAgent.c +++ b/CronosAgent.c @@ -128,8 +128,9 @@ #define EVENT_LIST_LENGTH (4 + 2 + 4) -#define BUFFER_SIZE 2048 -#define EXPIRATION_TIME 60 +#define BUFFER_SIZE 2048 // 2 KB +#define EXPIRATION_TIME 60 // 1 minute +#define INITIAL_INTERVAL 100 * 1000000 // 100 milliseconds int serviceMode = MODE_CONSOLE; @@ -247,6 +248,12 @@ int main(int argc, const char* argv[]) return EXIT_FAILURE; } + if (serviceMode & MODE_SYSLOG) + { + // Set proper origin for syslog (required by OpenWRT) + openlog("CronosAgent", LOG_NOWAIT | LOG_PID, LOG_USER); + } + #ifdef __linux__ if ((serviceMode & MODE_DAEMON) && (daemon(-1, -1) < 0)) @@ -376,7 +383,7 @@ int main(int argc, const char* argv[]) struct itimerspec timerInterval; memset(&timerInterval, 0, sizeof(timerInterval)); - timerInterval.it_value.tv_sec = REWIND_KEEP_ALIVE_INTERVAL; + timerInterval.it_value.tv_nsec = INITIAL_INTERVAL; timerInterval.it_interval.tv_sec = REWIND_KEEP_ALIVE_INTERVAL; timerHandle1 = timerfd_create(CLOCK_MONOTONIC, 0); diff --git a/OpenWRT/controller/cronosagent.lua b/OpenWRT/controller/cronosagent.lua index 81b65ce..a3ffcc8 100644 --- a/OpenWRT/controller/cronosagent.lua +++ b/OpenWRT/controller/cronosagent.lua @@ -3,10 +3,5 @@ module("luci.controller.cronosagent", package.seeall) function index() entry({ "admin", "cronosagent" }, alias("admin", "cronosagent", "configure", "restart"), "CronosAgent") entry({ "admin", "cronosagent", "configure" }, cbi("cronosagent/configure"), "Configure", 10) - entry({ "admin", "cronosagent", "restart" }, call("restartCronosAgent"), "Restart", 20) -end - -function restartCronosAgent() - luci.sys.call("/etc/init.d/cronosagent restart") - luci.http.write("Done!") + entry({ "admin", "cronosagent", "restart" }, template("cronosagent/restart"), "Restart", 20) end diff --git a/OpenWRT/view/cronosagent/restart.htm b/OpenWRT/view/cronosagent/restart.htm new file mode 100644 index 0000000..1044052 --- /dev/null +++ b/OpenWRT/view/cronosagent/restart.htm @@ -0,0 +1,9 @@ +<% + + luci.sys.call("/etc/init.d/cronosagent restart ; sleep 2") + +%> +<%+header%> +

CronosAgent

+ +<%+footer%> diff --git a/Version.h b/Version.h index 6ea5c38..986bb3b 100644 --- a/Version.h +++ b/Version.h @@ -1 +1 @@ -#define VERSION 20160811 +#define VERSION 20160812