Go to the documentation of this file. 1 #include "libmythbase/mythconfig.h"
2 #if CONFIG_SYSTEMD_NOTIFY
3 #include <systemd/sd-daemon.h>
11 #include <QCoreApplication>
13 #include <QApplication>
21 #include <QProcessEnvironment>
38 #include "libmythbase/mythversion.h"
60 #define LOC QString("MythBackend: ")
61 #define LOC_WARN QString("MythBackend, Warning: ")
62 #define LOC_ERR QString("MythBackend, Error: ")
71 int main(
int argc,
char **argv)
96 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
99 QCoreApplication a(argc, argv);
103 QApplication a(argc, argv);
108 QString path = QCoreApplication::applicationDirPath();
110 QString(
"%1/../Resources/lib/%2:/../Resources/lib/%2/site-packages:/../Resources/lib/%2/lib-dynload:%3")
112 .arg(QFileInfo(PYTHON_EXE).fileName())
113 .arg(QProcessEnvironment::systemEnvironment().value(
"PYTHONPATH"))
114 .toUtf8().constData(), 1);
122 QString mask(
"general");
131 #if CONFIG_SYSTEMD_NOTIFY
132 (void)sd_notify(0,
"STATUS=Connecting to database.");
153 if (!context.Init(
false,
false,
false,ignoreDB))
155 LOG(VB_GENERAL, LOG_CRIT,
"Failed to init MythContext.");
180 if (retval == 258 || retval == 259)
182 char ** newargv =
new char * [argc + 2];
183 std::string webonly =
"--webonly";
184 newargv[0] = argv[0];
186 for (
int ix = 1 ; ix < argc ; ++ix)
188 if (webonly != argv[ix])
189 newargv[newargc++] = argv[ix];
192 newargv[newargc++] = webonly.data();
193 newargv[newargc] =
nullptr;
194 LOG(VB_GENERAL, LOG_INFO,
195 QString(
"Restarting mythbackend"));
197 int rc = execvp(newargv[0], newargv);
198 LOG(VB_GENERAL, LOG_ERR,
199 QString(
"execvp failed prog %1 rc=%2 errno=%3").arg(argv[0]).arg(rc).arg(errno));
void setHttpProxy(void)
Get network proxy settings from OS, and use for [Q]Http[Comms].
MythCommFlagCommandLineParser cmdline
static constexpr const char * MYTH_APPNAME_MYTHBACKEND
Startup context for MythTV.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
int main(int argc, char **argv)
static WebOnlyStartup s_WebOnlyStartup
void InitializeMythDirs(void)
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
@ GENERIC_EXIT_OK
Exited with no error.
static void PrintVersion(void)
Print application version information.
void PrintHelp(void) const
Print command line option help.
int Daemonize(void) const
Fork application into background, and detatch from terminal.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void ApplySettingsOverride(void)
Apply all overrides to the global context.
static QString cleanup(const QString &str)
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
int handle_command(const MythBackendCommandLineParser &cmdline)
static constexpr long UNUSED_FILENO
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
int run_backend(MythBackendCommandLineParser &cmdline)
void SetAsBackend(bool backend)
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.