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>
34 #include "libmythbase/mythversion.h"
56 #define LOC QString("MythBackend: ")
57 #define LOC_WARN QString("MythBackend, Warning: ")
58 #define LOC_ERR QString("MythBackend, Error: ")
67 int main(
int argc,
char **argv)
89 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
91 QCoreApplication a(argc, argv);
95 QApplication a(argc, argv);
100 QString path = QCoreApplication::applicationDirPath();
102 QString(
"%1/../Resources/lib/%2/site-packages:%3")
104 .arg(QFileInfo(PYTHON_EXE).fileName())
105 .arg(QProcessEnvironment::systemEnvironment().value(
"PYTHONPATH"))
106 .toUtf8().constData(), 1);
114 QString mask(
"general");
128 #if CONFIG_SYSTEMD_NOTIFY
129 (void)sd_notify(0,
"STATUS=Connecting to database.");
137 bool ignoreDB =
false;
140 ignoreDB = !config.FileExists();
151 LOG(VB_GENERAL, LOG_CRIT,
"Failed to init MythContext.");
175 LOG(VB_GENERAL, LOG_INFO,
176 QString(
"Restarting mythbackend"));
178 int rc = execvp(argv[0], argv);
179 LOG(VB_GENERAL, LOG_ERR,
180 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.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
int main(int argc, char **argv)
@ GENERIC_EXIT_OK
Exited with no error.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
static constexpr const char * MYTH_APPNAME_MYTHBACKEND
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.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
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)