Go to the documentation of this file.
12 #include <QCoreApplication>
20 #include "libmythbase/mythconfig.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");
107 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to init MythContext, exiting.");
113 LOG(VB_GENERAL, LOG_ERR,
"Exiting due to schema mismatch.");
123 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to connect to master server");
130 std::cerr <<
"No setting found for this machine's BackendServerIP.\n"
131 <<
"Please run setup on this machine and modify the first page\n"
132 <<
"of the general settings.\n";
138 if (!sockmanager->Listen(port))
140 LOG(VB_GENERAL, LOG_ERR,
141 "Mediaserver exiting, failed to bind to listen port.");
151 sockmanager->RegisterHandler(controlRequestHandler);
152 controlRequestHandler->ConnectToMaster();
160 int exitCode = QCoreApplication::exec();
163 delete sysEventHandler;
@ GENERIC_EXIT_SETUP_ERROR
Incorrectly setup system.
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
MythCommFlagCommandLineParser cmdline
bool ConnectToMasterServer(bool blockingClient=true, bool openEventSocket=true)
Startup context for MythTV.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
@ GENERIC_EXIT_OK
Exited with no error.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
static constexpr const char * MYTH_APPNAME_MYTHMEDIASERVER
int GetBackendServerPort(void)
Returns the locally defined backend control port.
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
@ GENERIC_EXIT_SOCKET_ERROR
Socket 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.
static constexpr const char * MYTH_BINARY_VERSION
Update this whenever the plug-in ABI changes.
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)
@ GENERIC_EXIT_CONNECT_ERROR
Can't connect to master backend.
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
@ GENERIC_EXIT_DB_OUTOFDATE
Database needs upgrade.
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
Handles incoming MythSystemEvent messages.
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)