Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions src/bluez/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,31 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "bluez_client.h"

int main() {
try {
// Initialize logging with environment variable configuration
logging_config::initializeLogging("bluez_client");

installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

BluezClient client(*connection);

LOG_INFO("BlueZ client running - Press Ctrl+C to exit");

// Monitor loop with shared connection health timing defaults
auto result = monitorLoop(*connection);

if (result) {
// Connection was lost
LOG_ERROR("Exiting due to: {}", *result);
} else {
// Graceful shutdown via signal
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();

return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
27 changes: 11 additions & 16 deletions src/geoclue2/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <chrono>

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "geoclue2_manager.h"

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts so SIGINT/SIGTERM are
// blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

const GeoClue2Manager manager(
*connection, [&](const GeoClue2Location& location) {
Expand All @@ -40,7 +43,6 @@ int main() {
const auto& client = manager.Client();
if (!client) {
LOG_ERROR("GeoClue2 did not return a client object; cannot continue");
connection->leaveEventLoop();
return 1;
}

Expand All @@ -50,16 +52,9 @@ int main() {

LOG_INFO("Geoclue2 monitor daemon running - Press Ctrl+C to exit");

auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
25 changes: 11 additions & 14 deletions src/login1/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "login1_manager_client.h"

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

Login1ManagerClient client(*connection);

LOG_INFO("Login1 client running - Press Ctrl+C to exit");

// Monitor loop with shared connection health timing defaults
auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
26 changes: 11 additions & 15 deletions src/network1/main.cc
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "network1_client.h"

#include <chrono>

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

Network1ManagerClient network_manager(*connection);

LOG_INFO("network1 monitor daemon running - Press Ctrl+C to exit");

auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
24 changes: 11 additions & 13 deletions src/networkmanager/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "networkmanager_client.h"

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

NetworkManagerClient client(*connection);

LOG_INFO("NetworkManager monitor daemon running - Press Ctrl+C to exit");

auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
25 changes: 11 additions & 14 deletions src/resolve1/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "resolve1_manager.h"

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

Resolve1Manager manager(*connection);

LOG_INFO("Resolved client running - Press Ctrl+C to exit");

// Monitor loop with shared connection health timing defaults
auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
25 changes: 11 additions & 14 deletions src/systemd1/main.cc
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
#include <chrono>

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "systemd1_manager_client.h"

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

Systemd1ManagerClient manager(*connection);

LOG_INFO("Systemd1 monitor daemon running - Press Ctrl+C to exit");

auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
25 changes: 11 additions & 14 deletions src/udisks2/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../utils/signal_handler.h"
#include "../utils/event_loop.h"
#include "../utils/signal_source.h"
#include "udisks2_manager.h"

int main() {
try {
installSignalHandlers();
// Single-threaded loop drives the D-Bus connection and signal delivery.
// Construct the SignalSource before any thread starts (e.g. spdlog's
// flush thread) so SIGINT/SIGTERM are blocked and delivered via the loop.
EventLoop loop;
SignalSource signals(loop);
loop.add(&signals);

const auto connection = sdbus::createSystemBusConnection();
connection->enterEventLoopAsync();

UDisks2Manager manager(*connection);

LOG_INFO("UDisks2 client running - Press Ctrl+C to exit");

// Monitor loop with shared connection health timing defaults
auto result = monitorLoop(*connection);

if (result) {
LOG_ERROR("Exiting due to: {}", *result);
} else {
LOG_INFO("Shutting down...");
}

connection->leaveEventLoop();
return result ? 1 : 0;
const int rc = loop.run(*connection);
LOG_INFO("Shutting down...");
return rc;

} catch (const sdbus::Error& e) {
LOG_ERROR("D-Bus error: {} - {}", e.getName(), e.getMessage());
Expand Down
Loading
Loading