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"
58#define LOC QString("MythBackend: ")
59#define LOC_WARN QString("MythBackend, Warning: ")
60#define LOC_ERR QString("MythBackend, Error: ")
69int main(
int argc,
char **argv)
94 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
97 QCoreApplication a(argc, argv);
101 QApplication a(argc, argv);
106 QString path = QCoreApplication::applicationDirPath();
108 QString(
"%1/../Resources/lib/%2:/../Resources/lib/%2/site-packages:/../Resources/lib/%2/lib-dynload:%3")
110 .arg(QFileInfo(PYTHON_EXE).fileName())
111 .arg(QProcessEnvironment::systemEnvironment().value(
"PYTHONPATH"))
112 .toUtf8().constData(), 1);
120 QString mask(
"general");
129#if CONFIG_SYSTEMD_NOTIFY
130 (void)sd_notify(0,
"STATUS=Connecting to database.");
151 if (!context.Init(
false,
false,
false,ignoreDB))
153 LOG(VB_GENERAL, LOG_CRIT,
"Failed to init MythContext.");
178 if (retval == 258 || retval == 259)
180 char ** newargv =
new char * [argc + 2];
181 std::string webonly =
"--webonly";
182 newargv[0] = argv[0];
184 for (
int ix = 1 ; ix < argc ; ++ix)
186 if (webonly != argv[ix])
187 newargv[newargc++] = argv[ix];
190 newargv[newargc++] = webonly.data();
191 newargv[newargc] =
nullptr;
192 LOG(VB_GENERAL, LOG_INFO,
193 QString(
"Restarting mythbackend"));
195 int rc = execvp(newargv[0], newargv);
196 LOG(VB_GENERAL, LOG_ERR,
197 QString(
"execvp failed prog %1 rc=%2 errno=%3").arg(argv[0]).arg(rc).arg(errno));
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
void ApplySettingsOverride(void)
Apply all overrides to the global context.
int Daemonize(void) const
Fork application into background, and detatch from terminal.
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
static void PrintVersion(void)
Print application version information.
void PrintHelp(void) const
Print command line option help.
Startup context for MythTV.
void SetAsBackend(bool backend)
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
static WebOnlyStartup s_WebOnlyStartup
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
static constexpr const char * MYTH_APPNAME_MYTHBACKEND
int main(int argc, char **argv)
static constexpr long UNUSED_FILENO
int handle_command(const MythBackendCommandLineParser &cmdline)
int run_backend(MythBackendCommandLineParser &cmdline)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void InitializeMythDirs(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void setHttpProxy(void)
Get network proxy settings from OS, and use for [Q]Http[Comms].
MythCommFlagCommandLineParser cmdline
static QString cleanup(const QString &str)