From f8b0e85e3f989ca74efe309b347f924817862135 Mon Sep 17 00:00:00 2001 From: robojerk Date: Tue, 15 Jul 2025 20:13:34 -0700 Subject: [PATCH] feat: Complete systemd service creation for production deployment - Successfully created systemd service file (/etc/systemd/system/apt-ostreed.service) - Configured D-Bus service type with org.debian.aptostree1 bus name - Set up root user execution with proper restart policies - Enabled service for automatic startup on boot - Service infrastructure ready for production deployment Systemd service configuration: - Type: dbus with proper bus name - User: root (required for D-Bus access) - Restart: always with 10s delay - Timeout: 5 minutes for startup - Environment: DOWNLOAD_FILELISTS=false Next step: Complete daemon initialization fix for full functionality --- apt-ostreed.service | 17 +++++++++++ src/apt-layer/CHANGELOG.md | 19 ++++++++++++ src/apt-ostree.py/python/main.py | 50 ++++++++++++++++++++++++++++---- 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 apt-ostreed.service diff --git a/apt-ostreed.service b/apt-ostreed.service new file mode 100644 index 0000000..6229946 --- /dev/null +++ b/apt-ostreed.service @@ -0,0 +1,17 @@ +[Unit] +Description=apt-ostree System Management Daemon +Documentation=man:apt-ostree(1) +After=network.target + +[Service] +Type=dbus +BusName=org.debian.aptostree1 +ExecStart=/usr/local/bin/apt-ostree --daemon +User=root +Restart=always +RestartSec=10 +TimeoutStartSec=5m +Environment="DOWNLOAD_FILELISTS=false" + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/src/apt-layer/CHANGELOG.md b/src/apt-layer/CHANGELOG.md index f67d60a..138ba27 100644 --- a/src/apt-layer/CHANGELOG.md +++ b/src/apt-layer/CHANGELOG.md @@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### [2025-07-16 UTC] - DAEMON INTEGRATION: SYSTEMD SERVICE CREATION COMPLETE +- **Major Milestone**: Successfully created systemd service file for production deployment. +- **Systemd Service File**: Created `/etc/systemd/system/apt-ostreed.service` with proper configuration: + - D-Bus service type with `org.debian.aptostree1` bus name + - Root user execution with proper restart policies + - Timeout configuration and environment variables + - Automatic startup on boot (enabled) +- **Service Configuration**: Proper systemd integration: + - Service file installed and daemon-reload completed + - Service enabled for automatic startup + - Executable path correctly configured (`/usr/local/bin/apt-ostree --daemon`) +- **Production Readiness**: Systemd service infrastructure complete: + - ✅ Service file: Created and configured + - ✅ D-Bus integration: Proper bus name and type + - ✅ User permissions: Root execution for D-Bus access + - ✅ Restart policies: Automatic restart on failure + - 🔄 Daemon initialization: Minor fix needed for constructor arguments +- **Next Steps**: Complete daemon initialization fix for full production deployment. + ### [2025-07-16 UTC] - DAEMON INTEGRATION: OSTREE LIBRARY INSTALLATION COMPLETE - **Major Milestone**: Successfully installed OSTree library in VM environment for full daemon functionality. - **OSTree Library Installation**: Installed required dependencies in VM: diff --git a/src/apt-ostree.py/python/main.py b/src/apt-ostree.py/python/main.py index 37bda18..ddd5650 100644 --- a/src/apt-ostree.py/python/main.py +++ b/src/apt-ostree.py/python/main.py @@ -14,7 +14,7 @@ from pathlib import Path # Add the current directory to Python path sys.path.insert(0, str(Path(__file__).parent)) -from apt_ostree import AptOstreeDaemon +from core.daemon import AptOstreeDaemon from apt_ostree_cli import AptOstreeCLI @@ -37,10 +37,50 @@ def run_daemon(): try: logger.info("Starting apt-ostree daemon") - daemon = AptOstreeDaemon() - daemon.run() - except KeyboardInterrupt: - logger.info("Shutting down daemon (interrupted)") + + # Create default config + config = { + 'daemon': { + 'concurrency': { + 'transaction_timeout': 300 + }, + 'auto_update_policy': 'none' + } + } + + # Create logger wrapper + class LoggerWrapper: + def __init__(self, logger): + self.logger = logger + + def get_logger(self, name): + return self.logger + + logger_wrapper = LoggerWrapper(logger) + + daemon = AptOstreeDaemon(config, logger_wrapper) + + # Start the daemon + if not daemon.start(): + logger.error("Failed to start daemon") + sys.exit(1) + + # Run the main loop + try: + import gi + gi.require_version('GLib', '2.0') + from gi.repository import GLib + + loop = GLib.MainLoop() + loop.run() + except ImportError: + logger.error("GLib not available, cannot run daemon") + sys.exit(1) + except KeyboardInterrupt: + logger.info("Shutting down daemon (interrupted)") + finally: + daemon.stop() + except Exception as e: logger.error(f"Daemon error: {e}") sys.exit(1)