Go to the documentation of this file.
12 #include <QCoreApplication>
20 #include "libmythbase/mythconfig.h"
23 #include "libmythbase/mythversion.h"
36 #if CONFIG_SYSTEMD_NOTIFY
37 #include <systemd/sd-daemon.h>
38 static inline void ms_sd_notify(
const char *str) { sd_notify(0, str); };
43 #define LOC QString("MythMediaServer: ")
44 #define LOC_WARN QString("MythMediaServer, Warning: ")
45 #define LOC_ERR QString("MythMediaServer, Error: ")
57 unlink(
pidfile.toLatin1().constData());
64 int main(
int argc,
char *argv[])
85 QCoreApplication a(argc, argv);
93 QString mask(
"general");
108 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to init MythContext, exiting.");
114 LOG(VB_GENERAL, LOG_ERR,
"Exiting due to schema mismatch.");
124 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to connect to master server");
131 std::cerr <<
"No setting found for this machine's BackendServerIP.\n"
132 <<
"Please run setup on this machine and modify the first page\n"
133 <<
"of the general settings.\n";
139 if (!sockmanager->Listen(port))
141 LOG(VB_GENERAL, LOG_ERR,
142 "Mediaserver exiting, failed to bind to listen port.");
152 sockmanager->RegisterHandler(controlRequestHandler);
153 controlRequestHandler->ConnectToMaster();
161 int exitCode = QCoreApplication::exec();
164 delete sysEventHandler;
MythCommFlagCommandLineParser cmdline
bool ConnectToMasterServer(bool blockingClient=true, bool openEventSocket=true)
Startup context for MythTV.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
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.
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, [[maybe_unused]] const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
static constexpr const char * MYTH_APPNAME_MYTHMEDIASERVER
int GetBackendServerPort(void)
Returns the locally defined backend control port.
@ GENERIC_EXIT_OK
Exited with no error.
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
static void PrintVersion(void)
Print application version information.
@ GENERIC_EXIT_CONNECT_ERROR
Can't connect to master backend.
void PrintHelp(void) const
Print command line option help.
int Daemonize(void) const
Fork application into background, and detatch from terminal.
@ GENERIC_EXIT_DB_OUTOFDATE
Database needs upgrade.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void ApplySettingsOverride(void)
Apply all overrides to the global context.
static void Init(QObject *parent=nullptr)
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
@ GENERIC_EXIT_SETUP_ERROR
Incorrectly setup system.
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
Handles incoming MythSystemEvent messages.
@ GENERIC_EXIT_SOCKET_ERROR
Socket error.
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.