add systemd
This commit is contained in:
parent
1f0e13e334
commit
cfb6b41c57
@ -1,11 +1,11 @@
|
|||||||
/var/log/guhd.log {
|
/var/log/guhd.log {
|
||||||
weekly
|
daily
|
||||||
rotate 5
|
dateext
|
||||||
size 200M
|
rotate 7
|
||||||
|
size 10M
|
||||||
compress
|
compress
|
||||||
delaycompress
|
delaycompress
|
||||||
missingok
|
missingok
|
||||||
notifempty
|
notifempty
|
||||||
create 644 root root
|
create 644 root root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
data/systemd/guhd.service
Normal file
14
data/systemd/guhd.service
Normal file
@ -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
debian/guhd.1
vendored
23
debian/guhd.1
vendored
@ -23,6 +23,10 @@ Displays version information.
|
|||||||
\fB\-n\fR, \fB\-\-no\-daemon\fR
|
\fB\-n\fR, \fB\-\-no\-daemon\fR
|
||||||
Run guhd in the foreground, not as daemon.
|
Run guhd in the foreground, not as daemon.
|
||||||
.TP
|
.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
|
\fB\-d\fR, \fB\-\-debug\fR, \fB\<[No\]DebugCategory>\fR
|
||||||
Debug categories to enable. In order to disable a category which is enabled by
|
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
|
default, you can add \"No\" to the category. Warnings from all
|
||||||
@ -72,8 +76,21 @@ and enable debug messages for JsonRpc and LogEngine:
|
|||||||
.IP
|
.IP
|
||||||
$ guhd -n -d NoDeviceManager -d JsonRpc -d LogEngine
|
$ guhd -n -d NoDeviceManager -d JsonRpc -d LogEngine
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.TP
|
The server config file: \fI/etc/guh/guhd.conf\fR
|
||||||
The settings of the guh server can be found in \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
|
.SH SEE ALSO
|
||||||
Full developer documentation at: <http://dev.guh.guru>
|
Full developer documentation at: <http://dev.guh.guru>
|
||||||
.br
|
.br
|
||||||
@ -81,7 +98,7 @@ Wiki on github: <https://github.com/guh/guh/wiki>
|
|||||||
.SH "REPORTING BUGS"
|
.SH "REPORTING BUGS"
|
||||||
Issue tracker on github: <https://github.com/guh/guh/issues>
|
Issue tracker on github: <https://github.com/guh/guh/issues>
|
||||||
.br
|
.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
|
.SH AUTHOR
|
||||||
Written by Simon Stürz and Michael Zanetti
|
Written by Simon Stürz and Michael Zanetti
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
|
|||||||
1
debian/guhd.install
vendored
1
debian/guhd.install
vendored
@ -1,4 +1,3 @@
|
|||||||
usr/bin/guhd
|
usr/bin/guhd
|
||||||
data/init/* /etc/init.d
|
|
||||||
data/config/guhd.conf /etc/guh/
|
data/config/guhd.conf /etc/guh/
|
||||||
data/logrotate/guhd /etc/logrotate.d/
|
data/logrotate/guhd /etc/logrotate.d/
|
||||||
|
|||||||
@ -31,7 +31,6 @@
|
|||||||
\sa QtService
|
\sa QtService
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "guhservice.h"
|
#include "guhservice.h"
|
||||||
#include "loggingcategories.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. */
|
/*! Constructs the forked guhd application with the given argument count \a argc and argument vector \a argv. */
|
||||||
GuhService::GuhService(int argc, char **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()->setOrganizationName("guh");
|
||||||
application()->setApplicationName("guhd");
|
application()->setApplicationName("guhd");
|
||||||
application()->setApplicationVersion(GUH_VERSION_STRING);
|
application()->setApplicationVersion(GUH_VERSION_STRING);
|
||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
close(STDERR_FILENO);
|
close(STDERR_FILENO);
|
||||||
setServiceDescription("guh daemon");
|
setServiceDescription("guh - IoT server");
|
||||||
setServiceFlags(QtServiceBase::CanBeSuspended);
|
setServiceFlags(QtServiceBase::CanBeSuspended);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +59,17 @@ GuhService::~GuhService()
|
|||||||
/*! Starts the forked guhd application. */
|
/*! Starts the forked guhd application. */
|
||||||
void GuhService::start()
|
void GuhService::start()
|
||||||
{
|
{
|
||||||
|
qCDebug(dcApplication) << "=====================================";
|
||||||
|
qCDebug(dcApplication) << "guhd" << GUH_VERSION_STRING << "started as daemon.";
|
||||||
|
qCDebug(dcApplication) << "=====================================";
|
||||||
GuhCore::instance()->setRunningMode(GuhCore::RunningModeService);
|
GuhCore::instance()->setRunningMode(GuhCore::RunningModeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuhService::stop()
|
||||||
|
{
|
||||||
|
qCDebug(dcApplication) << "=====================================";
|
||||||
|
qCDebug(dcApplication) << "Shutting down guh daemon";
|
||||||
|
qCDebug(dcApplication) << "=====================================";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void start();
|
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");
|
QString timeString = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss.zzz");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
messageString = QString("I %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
messageString = QString(" I %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||||
fprintf(stdout, "I | %s: %s\n", context.category, message.toUtf8().data());
|
fprintf(stdout, " I | %s: %s\n", context.category, message.toUtf8().data());
|
||||||
break;
|
break;
|
||||||
case QtWarningMsg:
|
case QtWarningMsg:
|
||||||
messageString = QString("W %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
messageString = QString(" W %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||||
fprintf(stdout, "W | %s: %s\n", context.category, message.toUtf8().data());
|
fprintf(stdout, " W | %s: %s\n", context.category, message.toUtf8().data());
|
||||||
break;
|
break;
|
||||||
case QtCriticalMsg:
|
case QtCriticalMsg:
|
||||||
messageString = QString("C %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
messageString = QString(" C %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||||
fprintf(stdout, "C | %s: %s\n", context.category, message.toUtf8().data());
|
fprintf(stdout, " C | %s: %s\n", context.category, message.toUtf8().data());
|
||||||
break;
|
break;
|
||||||
case QtFatalMsg:
|
case QtFatalMsg:
|
||||||
messageString = QString("F %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
messageString = QString(" F %1 | %2: %3").arg(timeString).arg(context.category).arg(message);
|
||||||
fprintf(stdout, "F | %s: %s\n", context.category, message.toUtf8().data());
|
fprintf(stdout, " F | %s: %s\n", context.category, message.toUtf8().data());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile logFile(GuhSettings::consoleLogPath());
|
QFile logFile(GuhSettings::consoleLogPath());
|
||||||
if (!logFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
QTextStream textStream(&logFile);
|
QTextStream textStream(&logFile);
|
||||||
|
|||||||
Reference in New Issue
Block a user