|
Mailer 1.0.5
C++ daemon for sending order emails via SMTP
|
#include <constants.h>#include <email_sender.h>#include <ini.h>#include <logger.h>#include <products.h>#include <atomic>#include <csignal>#include <cstdlib>#include <iostream>#include <limits.h>#include <pqxx/pqxx>#include <setjmp.h>#include <string>#include <unistd.h>#include <unordered_set>Go to the source code of this file.
Classes | |
| class | Daemon |
Macros | |
| #define | SUCCESS (0) |
| #define | FAILURE (-1) |
Functions | |
| static void | sigIntHandler (int signal) |
| Обработчик сигналов завершения (SIGINT/SIGTERM/SIGABRT/SIGFPE/SIGILL). | |
| static void | sigsegvhandler (int signal) |
| Обработчик segmentation fault — перезапускает цикл. | |
| static std::string | getApplicationDirectory () |
| Возвращает директорию, в которой находится исполняемый файл. | |
| int | main (void) |
Variables | |
| volatile std::sig_atomic_t | gSignalStatus |
| Глобальный флаг последнего полученного сигнала. | |
| jmp_buf | return_to_main |
| jmp_buf для graceful shutdown (SIGINT/SIGTERM). | |
| jmp_buf | return_to_bottom |
| jmp_buf для перезапуска цикла после SIGSEGV. | |
| static Daemon * | d |
| Глобальный указатель на демон (доступен из signal handler'ов). | |
| #define FAILURE (-1) |
Definition at line 19 of file mailer.cpp.
Referenced by EmailSender::send(), and Daemon::sendOrders().
| #define SUCCESS (0) |
Definition at line 18 of file mailer.cpp.
Referenced by Daemon::Run(), EmailSender::send(), and Daemon::sendOrders().
|
static |
Возвращает директорию, в которой находится исполняемый файл.
Возвращает директорию исполняемого файла.
Читает символическую ссылку /proc/self/exe и извлекает путь к родительской директории. Конфиг и лог-файл ищутся рядом с бинарником.
Definition at line 417 of file mailer.cpp.
Referenced by Daemon::Daemon().
| int main | ( | void | ) |
Точка входа.
Устанавливает обработчики сигналов, создаёт Daemon, запускает цикл Run(). При SIGINT/SIGTERM/SIGABRT/SIGFPE/SIGILL происходит longjmp в эту же функцию для graceful shutdown (Stop() + delete).
Definition at line 363 of file mailer.cpp.
References d, return_to_main, Daemon::Run(), sigIntHandler(), sigsegvhandler(), and Daemon::Stop().
|
static |
Обработчик сигналов завершения (SIGINT/SIGTERM/SIGABRT/SIGFPE/SIGILL).
Обработчик сигналов завершения.
Выполняет longjmp в main() для штатной остановки демона.
| [in] | signal | Номер сигнала (SIGINT/SIGTERM/SIGABRT/SIGFPE/SIGILL). |
Definition at line 395 of file mailer.cpp.
References return_to_main.
Referenced by main().
|
static |
Обработчик segmentation fault — перезапускает цикл.
Обработчик segmentation fault.
Выполняет longjmp в точку return_to_bottom внутри цикла Run(), позволяя демону продолжить работу без полного перезапуска.
| [in] | signal | Номер сигнала (SIGSEGV). |
Definition at line 406 of file mailer.cpp.
References return_to_bottom.
Referenced by main().
|
static |
Глобальный указатель на демон (доступен из signal handler'ов).
Definition at line 355 of file mailer.cpp.
Referenced by main().
| volatile std::sig_atomic_t gSignalStatus |
Глобальный флаг последнего полученного сигнала.
Definition at line 22 of file mailer.cpp.
| jmp_buf return_to_bottom |
jmp_buf для перезапуска цикла после SIGSEGV.
Definition at line 27 of file mailer.cpp.
Referenced by Daemon::Run(), and sigsegvhandler().
| jmp_buf return_to_main |
jmp_buf для graceful shutdown (SIGINT/SIGTERM).
Definition at line 25 of file mailer.cpp.
Referenced by main(), and sigIntHandler().