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>
36 #include "libmythbase/mythversion.h"
58 #define LOC QString("MythBackend: ")
59 #define LOC_WARN QString("MythBackend, Warning: ")
60 #define LOC_ERR QString("MythBackend, Error: ")
69 int 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");
135 #if CONFIG_SYSTEMD_NOTIFY
136 (void)sd_notify(0,
"STATUS=Connecting to database.");
144 bool ignoreDB =
false;
147 ignoreDB = !config.FileExists();
160 LOG(VB_GENERAL, LOG_CRIT,
"Failed to init MythContext.");
184 if (retval == 258 || retval == 259)
186 char ** newargv =
new char * [argc + 2];
187 std::string webonly =
"--webonly";
188 newargv[0] = argv[0];
190 for (
int ix = 1 ; ix < argc ; ++ix)
192 if (webonly != argv[ix])
193 newargv[newargc++] = argv[ix];
196 newargv[newargc++] = webonly.data();
197 newargv[newargc] =
nullptr;
198 LOG(VB_GENERAL, LOG_INFO,
199 QString(
"Restarting mythbackend"));
201 int rc = execvp(newargv[0], newargv);
202 LOG(VB_GENERAL, LOG_ERR,
203 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
Startup context for MythTV.
void setWebOnly(WebOnlyStartup w)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
int main(int argc, char **argv)
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.
static constexpr const char * MYTH_APPNAME_MYTHBACKEND
@ 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)
static void Init(QObject *parent=nullptr)
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)
MythContext * gContext
This global variable contains the MythContext instance for the application.
bool Init(bool gui=true, bool promptForBackend=false, bool disableAutoDiscovery=false, bool ignoreDB=false)
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.