1
1
//////////////////////////////////////////////////////////////////////////
3
3
// pgAgent - PostgreSQL Tools
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
5
// Copyright (C) 2002 - 2012, The pgAdmin Development Team
6
// This software is released under the PostgreSQL Licence
8
8
// unix.cpp - pgAgent unix specific functions
21
21
void usage(const wxString &executable)
23
wxFileName *fn = new wxFileName(executable);
23
wxFileName *fn = new wxFileName(executable);
25
wxPrintf(_("Usage:\n"));
26
wxPrintf(fn->GetName() + _(" [options] <connect-string>\n"));
27
wxPrintf(_("options:\n"));
28
wxPrintf(_("-f run in the foreground (do not detach from the terminal)\n"));
29
wxPrintf(_("-t <poll time interval in seconds (default 10)>\n"));
30
wxPrintf(_("-r <retry period after connection abort in seconds (>=10, default 30)>\n"));
31
wxPrintf(_("-s <log file (messages are logged to STDOUT if not specified>\n"));
32
wxPrintf(_("-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>\n"));
25
wxPrintf(_("Usage:\n"));
26
wxPrintf(fn->GetName() + _(" [options] <connect-string>\n"));
27
wxPrintf(_("options:\n"));
28
wxPrintf(_("-f run in the foreground (do not detach from the terminal)\n"));
29
wxPrintf(_("-t <poll time interval in seconds (default 10)>\n"));
30
wxPrintf(_("-r <retry period after connection abort in seconds (>=10, default 30)>\n"));
31
wxPrintf(_("-s <log file (messages are logged to STDOUT if not specified>\n"));
32
wxPrintf(_("-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>\n"));
35
35
void LogMessage(wxString msg, int level)
38
if (logFile.IsEmpty())
44
file.Open(logFile.c_str(), wxT("a"));
49
wxFprintf(stderr, _("Can not open the logfile!"));
56
if (minLogLevel >= LOG_DEBUG)
57
file.Write(_("DEBUG: ") + msg + wxT("\n"));
60
if (minLogLevel >= LOG_WARNING)
61
file.Write(_("WARNING: ") + msg + wxT("\n"));
64
file.Write(_("ERROR: ") + msg + wxT("\n"));
68
file.Write(_("WARNING: ") + msg + wxT("\n"));
72
if (logFile.IsEmpty())
38
if (logFile.IsEmpty())
44
file.Open(logFile.c_str(), wxT("a"));
49
wxFprintf(stderr, _("Can not open the logfile!"));
56
if (minLogLevel >= LOG_DEBUG)
57
file.Write(_("DEBUG: ") + msg + wxT("\n"));
60
if (minLogLevel >= LOG_WARNING)
61
file.Write(_("WARNING: ") + msg + wxT("\n"));
64
file.Write(_("ERROR: ") + msg + wxT("\n"));
68
file.Write(_("WARNING: ") + msg + wxT("\n"));
72
if (logFile.IsEmpty())
82
82
// Shamelessly lifted from pg_autovacuum...
83
83
static void daemonize(void)
88
if (pid == (pid_t) -1)
90
LogMessage(_("Cannot disassociate from controlling TTY"), LOG_ERROR);
88
if (pid == (pid_t) - 1)
90
LogMessage(_("Cannot disassociate from controlling TTY"), LOG_ERROR);
99
LogMessage(_("Cannot disassociate from controlling TTY"), LOG_ERROR);
99
LogMessage(_("Cannot disassociate from controlling TTY"), LOG_ERROR);
106
106
int main(int argc, char **argv)
112
executable = wxString::FromAscii(argv[0]);
123
setOptions(argc, argv, executable);
125
if (!runInForeground)
112
executable = wxString::FromAscii(argv[0]);
123
setOptions(argc, argv, executable);
125
if (!runInForeground)