mirror of https://github.com/nymea/nymea.git
add systemd
parent
1f0e13e334
commit
cfb6b41c57
|
|
@ -1,11 +1,11 @@
|
|||
/var/log/guhd.log {
|
||||
weekly
|
||||
rotate 5
|
||||
size 200M
|
||||
daily
|
||||
dateext
|
||||
rotate 7
|
||||
size 10M
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
create 644 root root
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=guhd - IoT server
|
||||
Documentation=https://github.com/guh/guh/wiki
|
||||
After=network.target syslog.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/guhd --print-all
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
Restart=on-failure
|
||||
Type=forking
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -23,6 +23,10 @@ Displays version information.
|
|||
\fB\-n\fR, \fB\-\-no\-daemon\fR
|
||||
Run guhd in the foreground, not as daemon.
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-\-print\-all\fR
|
||||
Enables all debug categories. This parameter overrides all debug
|
||||
category parameters.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-debug\fR, \fB\<[No\]DebugCategory>\fR
|
||||
Debug categories to enable. In order to disable a category which is enabled by
|
||||
default, you can add \"No\" to the category. Warnings from all
|
||||
|
|
@ -72,8 +76,21 @@ and enable debug messages for JsonRpc and LogEngine:
|
|||
.IP
|
||||
$ guhd -n -d NoDeviceManager -d JsonRpc -d LogEngine
|
||||
.SH FILES
|
||||
.TP
|
||||
The settings of the guh server can be found in \fI/etc/guh/guhd.conf\fR
|
||||
The server config file: \fI/etc/guh/guhd.conf\fR
|
||||
.br
|
||||
The devices config file: \fI/etc/guh/devices.conf\fR
|
||||
.br
|
||||
The rules config file: \fI/etc/guh/rules.conf\fR
|
||||
.br
|
||||
The plugins config file: \fI/etc/guh/plugins.conf\fR
|
||||
.br
|
||||
The log file: \fI/var/log/guhd.log\fR
|
||||
.br
|
||||
The logging database: \fI/var/log/guhd.sqlite\fR
|
||||
.br
|
||||
The systemd unit file: \fI/etc/systemd/system/guhd.service\fR
|
||||
.br
|
||||
The plugins directory: \fI/usr/lib/guh/plugins/\fR
|
||||
.SH SEE ALSO
|
||||
Full developer documentation at: <http://dev.guh.guru>
|
||||
.br
|
||||
|
|
@ -81,7 +98,7 @@ Wiki on github: <https://github.com/guh/guh/wiki>
|
|||
.SH "REPORTING BUGS"
|
||||
Issue tracker on github: <https://github.com/guh/guh/issues>
|
||||
.br
|
||||
How to report bugs can: <https://github.com/guh/guh/wiki/Reporting-bugs>
|
||||
How to report bugs: <https://github.com/guh/guh/wiki/Reporting-bugs>
|
||||
.SH AUTHOR
|
||||
Written by Simon Stürz and Michael Zanetti
|
||||
.SH COPYRIGHT
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
usr/bin/guhd
|
||||
data/init/* /etc/init.d
|
||||
data/config/guhd.conf /etc/guh/
|
||||
data/logrotate/guhd /etc/logrotate.d/
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
\sa QtService
|
||||
*/
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#include "guhservice.h"
|
||||
#include "loggingcategories.h"
|
||||
|
|
@ -40,16 +39,15 @@ namespace guhserver {
|
|||
|
||||
/*! Constructs the forked guhd application with the given argument count \a argc and argument vector \a argv. */
|
||||
GuhService::GuhService(int argc, char **argv):
|
||||
QtService<QCoreApplication>(argc, argv, "guh daemon")
|
||||
QtService<QCoreApplication>(argc, argv, "guh - IoT server")
|
||||
{
|
||||
qDebug() << "guhd started as daemon.";
|
||||
application()->setOrganizationName("guh");
|
||||
application()->setApplicationName("guhd");
|
||||
application()->setApplicationVersion(GUH_VERSION_STRING);
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
setServiceDescription("guh daemon");
|
||||
setServiceDescription("guh - IoT server");
|
||||
setServiceFlags(QtServiceBase::CanBeSuspended);
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +59,17 @@ GuhService::~GuhService()
|
|||
/*! Starts the forked guhd application. */
|
||||
void GuhService::start()
|
||||
{
|
||||
qCDebug(dcApplication) << "=====================================";
|
||||
qCDebug(dcApplication) << "guhd" << GUH_VERSION_STRING << "started as daemon.";
|
||||
qCDebug(dcApplication) << "=====================================";
|
||||
GuhCore::instance()->setRunningMode(GuhCore::RunningModeService);
|
||||
}
|
||||
|
||||
void GuhService::stop()
|
||||
{
|
||||
qCDebug(dcApplication) << "=====================================";
|
||||
qCDebug(dcApplication) << "Shutting down guh daemon";
|
||||
qCDebug(dcApplication) << "=====================================";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
protected:
|
||||
void start();
|
||||
void stop();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,26 +60,26 @@ void consoleLogHandler(QtMsgType type, const QMessageLogContext& context, const
|
|||
QString timeString = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss.zzz");
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
messageString = QString("I %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, "I | %s: %s\n", context.category, message.toUtf8().data());
|
||||
messageString = QString(" I %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, " I | %s: %s\n", context.category, message.toUtf8().data());
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
messageString = QString("W %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, "W | %s: %s\n", context.category, message.toUtf8().data());
|
||||
messageString = QString(" W %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, " W | %s: %s\n", context.category, message.toUtf8().data());
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
messageString = QString("C %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, "C | %s: %s\n", context.category, message.toUtf8().data());
|
||||
messageString = QString(" C %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, " C | %s: %s\n", context.category, message.toUtf8().data());
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
messageString = QString("F %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, "F | %s: %s\n", context.category, message.toUtf8().data());
|
||||
messageString = QString(" F %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||
fprintf(stdout, " F | %s: %s\n", context.category, message.toUtf8().data());
|
||||
break;
|
||||
}
|
||||
|
||||
QFile logFile(GuhSettings::consoleLogPath());
|
||||
if (!logFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
fprintf(stdout, "W | Application: Could not open logfile.\n");
|
||||
fprintf(stdout, " W | Application: Could not open logfile.\n");
|
||||
return;
|
||||
}
|
||||
QTextStream textStream(&logFile);
|
||||
|
|
|
|||
Loading…
Reference in New Issue