BuildRequires: gperf
BuildRequires: pkgconfig(cynara-creds-pid)
BuildRequires: pkgconfig(security-manager)
+BuildRequires: pkgconfig(hal-api-common)
# for swap plugin
Requires: %{_sbindir}/mkswap
%license LICENSE
%manifest resourced.manifest
%{_libdir}/libresourced-private-api.so.*
+%{_libdir}/hal/libhal-backend-service-resourced.so
%{_bindir}/resourced
%dir %{plugindir}
%attr(-,root, root) %{_bindir}/resourced
aul
cynara-creds-pid
security-manager
+ hal-api-common
)
INCLUDE(FindPkgConfig)
INSTALL(FILES ${CONF_DIR}/process.conf
DESTINATION ${RD_CONFIG_PATH} RENAME process.conf)
+
+
+SET(LIBRARY_NAME "hal-backend-service-resourced")
+
+ADD_LIBRARY(${LIBRARY_NAME} SHARED
+ ${RESOURCED_SOURCE_DIR}/init.c
+ ${RESOURCED_SOURCE_DIR}/main.c
+ ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
+ resourced-private-api
+ ${RESOURCED_REQUIRE_PKGS_LDFLAGS}
+ "-pie -ldl -lm -Wl,-rpath=${RD_PLUGIN_PATH}")
+SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=default")
+SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SKIP_BUILD_RPATH true)
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIB_INSTALL_DIR}/hal COMPONENT RuntimeLibraries)
#include <mcheck.h>
#include <systemd/sd-daemon.h>
+#include <hal/hal-common.h>
+
int main(int argc, char **argv)
{
GMainLoop *mainloop = get_main_loop();
resourced_deinit();
return ret_code;
}
+
+static int resourced_module_init(void *data)
+{
+ GMainLoop *mainloop = get_main_loop();
+ int ret_code = 0;
+ struct daemon_arg darg = { 0, NULL, NULL };
+
+ assert(mainloop);
+
+ ret_code = resourced_init(&darg);
+ ret_value_msg_if(ret_code < 0, ret_code,
+ "Resourced initialization failed\n");
+ init_modules_arg(&darg);
+ modules_check_runtime_support(NULL);
+
+ /* parse vendor specific configuration files.
+ * resourced currently supports two dirs called limiter.conf.d and process.conf.d
+ * ex) /etc/resourced/xxx.d/yyy.conf
+ */
+ resourced_parse_vendor_configs();
+ register_notifier(RESOURCED_NOTIFIER_BOOTING_DONE, fixed_service_and_process_list_init);
+
+ if (resourced_restarted()) {
+ _I("Relaunched. Start to initialize and restore");
+ modules_init(NULL);
+ modules_restore(NULL);
+ } else {
+ _I("Initial instance: initializing all modules indiscriminately");
+ modules_init(NULL);
+ }
+
+ if (resourced_restarted()) {
+ modules_init_late(NULL);
+ resourced_notify(RESOURCED_NOTIFIER_BOOTING_DONE, NULL);
+ }
+
+ sd_notify(0, "READY=1");
+
+ g_main_loop_run(mainloop);
+
+ return 0;
+}
+
+static int resourced_module_exit(void *data)
+{
+ unregister_notifier(RESOURCED_NOTIFIER_BOOTING_DONE, fixed_service_and_process_list_init);
+
+ /* free all allocated memory to store configuration information */
+ resourced_free_vendor_configs();
+
+ modules_exit(NULL);
+ resourced_deinit();
+
+ return 0;
+}
+
+__attribute__((visibility("default")))
+hal_backend_service hal_backend_service_resourced_data = {
+ .module = HAL_MODULE_RESOURCED,
+ .name = "hal-backend-service-resourced",
+ .early_init = NULL,
+ .init = resourced_module_init,
+ .exit = resourced_module_exit,
+ .late_exit = NULL,
+};
[Unit]
Description=Resource management daemon
-# resourced monitors AUL (lauchpad) d-bus signals to learn about existence
-# and the state of applications. Consequently, it has to start before
-# launchpad to have knowledge of all applications. The Before= line below
-# refers to user-sessions, because tlm, and consequently user@.service
-# starts after user-sessions are allowed.
-Before=systemd-user-sessions.service
-DefaultDependencies=no
-Requires=resourced.socket
[Service]
Type=simple
-SmackProcessLabel=System
-ExecStart=/usr/bin/resourced
-MemoryMax=50M
-Restart=on-failure
-RestartSec=0
[Install]
WantedBy=multi-user.target