2 * =====================================================================================
4 * Filename: SimulatorDaemon.cpp
6 * Description: SimulatorDaemon main file
9 * Created: 16 April 2015 12:42:03 IST
13 * Author: CHERYL (cb), cheryl.b@samsung.com
14 * Organization: Samsung Electronics
16 * =====================================================================================
19 /*-----------------------------------------------------------------------------
21 *-----------------------------------------------------------------------------*/
23 #include "SimulatorDaemonServer.h"
25 /*-----------------------------------------------------------------------------
27 *-----------------------------------------------------------------------------*/
29 * Create shm file for shared memory implementation (IPC)
31 void initializeShm() {
32 LOGD(SIM_DAEMON, "Entry");
34 int fd = creat(SHM_PATH, S_IRWXU);
36 LOGE(SIM_DAEMON, "shm file creation failed");
43 * Starts the Simulator Daemon as server which listens for connection from
47 void startServer(boost::asio::io_service& io_service) {
48 LOGD(SIM_DAEMON, "Entry");
51 } catch (std::exception& e) {
52 LOGE(SIM_DAEMON, "Exception: %s", e.what());
57 * Stops the Simulator Daemon server
59 void stopServer(boost::asio::io_service& io_service) {
60 LOGD(SIM_DAEMON, "Entry");
65 * main function for Simulator Daemon
69 LOGD(SIM_DAEMON, "Entry");
72 ::unlink(SIMDAEMON_PATH);
74 SimulatorDaemonServer s(ioService::getInstance(), SIMDAEMON_PATH);
75 // Once the server is started, it exits only after the
76 // connection is lost or gracefully disconnected.
77 startServer(ioService::getInstance());
78 syslog(LOG_INFO | LOG_USER, "Daemon stopped");
79 } catch (std::exception& e) {
80 syslog(LOG_ERR | LOG_USER, "Exception: %s", e.what());
81 LOGE(SIM_DAEMON, "Exception: %s", e.what());
83 stopServer(ioService::getInstance());