1#include "libmythbase/mythconfig.h"
2#if CONFIG_SYSTEMD_NOTIFY
3 #include <systemd/sd-daemon.h>
11#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
12#include <QtSystemDetection>
15#include <QCoreApplication>
17#include <QApplication>
25#include <QProcessEnvironment>
42#include "libmythbase/mythversion.h"
62#define LOC QString("MythBackend: ")
63#define LOC_WARN QString("MythBackend, Warning: ")
64#define LOC_ERR QString("MythBackend, Error: ")
73int main(
int argc,
char **argv)
98 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
101 QCoreApplication a(argc, argv);
105 QApplication a(argc, argv);
110 QString path = QCoreApplication::applicationDirPath();
112 QString(
"%1/../Resources/lib/%2:/../Resources/lib/%2/site-packages:/../Resources/lib/%2/lib-dynload:%3")
114 .arg(QFileInfo(PYTHON_EXE).fileName())
115 .arg(QProcessEnvironment::systemEnvironment().value(
"PYTHONPATH"))
116 .toUtf8().constData(), 1);
124 QString mask(
"general");
133#if CONFIG_SYSTEMD_NOTIFY
134 (void)sd_notify(0,
"STATUS=Connecting to database.");
155 if (!context.Init(
false,
false,
false,ignoreDB))
157 LOG(VB_GENERAL, LOG_CRIT,
"Failed to init MythContext.");
182 if (retval == 258 || retval == 259)
184 char ** newargv =
new char * [argc + 2];
185 std::string webonly =
"--webonly";
186 newargv[0] = argv[0];
188 for (
int ix = 1 ; ix < argc ; ++ix)
190 if (webonly != argv[ix])
191 newargv[newargc++] = argv[ix];
194 newargv[newargc++] = webonly.data();
195 newargv[newargc] =
nullptr;
196 LOG(VB_GENERAL, LOG_INFO,
197 QString(
"Restarting mythbackend"));
198 std::this_thread::sleep_for(50ms);
199 int rc = execvp(newargv[0], newargv);
200 LOG(VB_GENERAL, LOG_ERR,
201 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)