v1.6.t5
Added a signal handler that will print out signal details upon receiving them. This should give up some hint to the cause of crashes for debugging reasons. The root index web page will now only be updated once. Hopefully this reduces chance of multiple instances clashing with each other.
This commit is contained in:
parent
f4f1f62d25
commit
6ffe80b672
|
@ -28,6 +28,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
#include <opencv4/opencv2/videoio.hpp>
|
||||
|
@ -36,7 +37,7 @@ using namespace cv;
|
|||
using namespace std;
|
||||
using namespace std::filesystem;
|
||||
|
||||
#define APP_VER "1.6.t4"
|
||||
#define APP_VER "1.6.t5"
|
||||
#define APP_NAME "Motion Watch"
|
||||
#define TRIM_REMOVE " \n\r\t\f\v."
|
||||
|
||||
|
@ -64,6 +65,7 @@ struct shared_t
|
|||
string webRoot;
|
||||
bool init;
|
||||
bool skipCmd;
|
||||
bool updateRoot;
|
||||
int cmdFinished;
|
||||
int clipLen;
|
||||
int frameGap;
|
||||
|
|
46
src/main.cpp
46
src/main.cpp
|
@ -141,8 +141,6 @@ void recLoop(shared_t *share)
|
|||
{
|
||||
while (rdConf(share))
|
||||
{
|
||||
recLog("rec_loop() -- start", share);
|
||||
|
||||
enforceMaxLogSize(share->recLogPath, share);
|
||||
enforceMaxLogSize(share->detLogPath, share);
|
||||
|
||||
|
@ -151,7 +149,9 @@ void recLoop(shared_t *share)
|
|||
|
||||
initLogFrontPages(share);
|
||||
|
||||
if (!exists("/tmp/mow-lock"))
|
||||
recLog("rec_loop() -- start", share);
|
||||
|
||||
if (!exists("/tmp/mow-lock") && share->updateRoot)
|
||||
{
|
||||
system("touch /tmp/mow-lock");
|
||||
|
||||
|
@ -160,10 +160,8 @@ void recLoop(shared_t *share)
|
|||
|
||||
remove("/tmp/mow-lock");
|
||||
recLog("webroot page updated: " + cleanDir(share->webRoot) + "/index.html", share);
|
||||
}
|
||||
else
|
||||
{
|
||||
recLog("skipping update of the webroot page, it is busy.", share);
|
||||
|
||||
share->updateRoot = false;
|
||||
}
|
||||
|
||||
genHTMLul(share->outDir, share->camName, share);
|
||||
|
@ -238,10 +236,37 @@ void recLoop(shared_t *share)
|
|||
}
|
||||
}
|
||||
|
||||
void sigHandler(int signal, siginfo_t *info, void *context)
|
||||
{
|
||||
cerr << "received signal details: " << endl;
|
||||
cerr << "-- si_pid: " << info->si_pid << endl;
|
||||
cerr << "-- si_signo: " << info->si_signo << endl;
|
||||
cerr << "-- si_code: " << info->si_code << endl;
|
||||
cerr << "-- si_errno: " << info->si_errno << endl;
|
||||
cerr << "-- si_uid: " << info->si_uid << endl;
|
||||
cerr << "-- si_addr: " << info->si_addr << endl;
|
||||
cerr << "-- si_status: " << info->si_status << endl;
|
||||
cerr << "-- si_band: " << info->si_band << endl;
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct shared_t sharedRes;
|
||||
|
||||
struct sigaction act = { 0 };
|
||||
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.sa_sigaction = &sigHandler;
|
||||
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
sigaction(SIGABRT, &act, NULL);
|
||||
sigaction(SIGSEGV, &act, NULL);
|
||||
sigaction(SIGILL, &act, NULL);
|
||||
sigaction(SIGFPE, &act, NULL);
|
||||
sigaction(SIGBUS, &act, NULL);
|
||||
|
||||
sharedRes.conf = parseForList("-c", argc, argv);
|
||||
|
||||
if (parseForParam("-h", argc, argv, true) == "true")
|
||||
|
@ -266,9 +291,10 @@ int main(int argc, char** argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
sharedRes.retCode = 0;
|
||||
sharedRes.skipCmd = false;
|
||||
sharedRes.init = true;
|
||||
sharedRes.retCode = 0;
|
||||
sharedRes.updateRoot = true;
|
||||
sharedRes.skipCmd = false;
|
||||
sharedRes.init = true;
|
||||
|
||||
recLoop(&sharedRes);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user