Skip to content

Commit

Permalink
#37: main process exited, code=exited, status=1/FAILURE
Browse files Browse the repository at this point in the history
  • Loading branch information
ballle98 committed Sep 8, 2019
1 parent d39863d commit 2f08dd8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions aqualinkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,7 @@ int main(int argc, char *argv[])
bool cmdln_debugRS485 = false;

// struct lws_context_creation_info info;
// Log only NOTICE messages and above. Debug and info messages
// will not be logged to syslog.
setlogmask(LOG_UPTO(LOG_NOTICE));
setlogmask(LOG_UPTO(LOG_DEBUG));

if (getuid() != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion net_services.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void action_web_request(struct mg_connection *nc, struct http_message *http_msg)
free(uri);
}
// If we have a get request, pass it
if (strstr(http_msg->method.p, "GET") && http_msg->query_string.len > 0) {
if ((mg_vcasecmp(&http_msg->method, "GET")==0) && http_msg->query_string.len > 0) {
char command[20];

mg_get_http_var(&http_msg->query_string, "command", command, sizeof(command));
Expand Down
2 changes: 1 addition & 1 deletion net_services_habridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void* habridge_updater_routine(void* data)
on_value = "false";
}
snprintf(cmd_buff, sizeof(cmd_buff),
"curl -sS -X PUT -d '{\"on\": %s}' 'http://%s/api/%s/lights/%d/bridgeupdatestate' > /dev/null",
"curl -sS -X PUT -d '{\"on\": %s}' 'http://%s/api/%s/lights/%d/bridgeupdatestate' > /dev/null 2>&1",
on_value, aqconfig->habridge_server,
aqconfig->habridge_user, aqdata->aqbuttons[i].hab_id);
logMessage (LOG_DEBUG, "habridge_updater_routine %s\n", cmd_buff);
Expand Down
10 changes: 5 additions & 5 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ void displayLastSystemError (const char *on_what)
if (_daemonise == TRUE)
{
logMessage (LOG_ERR, "%d : %s", errno, on_what);
closelog ();
}
}

Expand Down Expand Up @@ -327,7 +326,7 @@ void test(int msg_level, char *msg)
}
}


//:TODO: http://man7.org/linux/man-pages/man3/syslog.3.html
void logMessage(int msg_level, char *format, ...)
{
// Simply return ASAP.
Expand All @@ -347,9 +346,10 @@ void logMessage(int msg_level, char *format, ...)

// Logging has not been setup yet, so STD error & syslog
if (_log_level == -1) {
fprintf (stderr, buffer);
if (_daemonise == FALSE) {
fprintf (stderr, buffer);
}
syslog (msg_level, "%s", &buffer[8]);
closelog ();
}

if (_daemonise == TRUE)
Expand All @@ -358,7 +358,6 @@ void logMessage(int msg_level, char *format, ...)
syslog (LOG_DEBUG, "%s", &buffer[8]);
else
syslog (msg_level, "%s", &buffer[8]);
closelog ();
//return;
}

Expand Down Expand Up @@ -405,6 +404,7 @@ void logMessage(int msg_level, char *format, ...)
}
}

// :TODO: compare to https://github.com/pasce/daemon-skeleton-linux-c
void daemonise (char *pidFile, void (*main_function) (void))
{
FILE *fp = NULL;
Expand Down

0 comments on commit 2f08dd8

Please sign in to comment.