Merge branch 'feature/app-bootstrap-4995' into next

Fixes #4995
This commit is contained in:
Gunnar Beutner 2013-11-05 08:34:48 +01:00
commit 67b82a81c9
11 changed files with 164 additions and 3 deletions

View File

@ -115,10 +115,12 @@ static bool LoadConfigFiles(const String& appType, bool validateOnly)
return true;
}
#ifndef _WIN32
static void SigHupHandler(int)
{
Application::RequestRestart();
}
#endif /* _WIN32 */
static bool Daemonize(const String& stderrFile)
{

View File

@ -17,6 +17,8 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
library "methods"
template CheckCommand "plugin-check-command" {
methods = {
execute = "PluginCheck"

View File

@ -20,3 +20,4 @@ add_subdirectory(config)
add_subdirectory(icinga)
add_subdirectory(db_ido)
add_subdirectory(methods)
add_subdirectory(hello)

View File

@ -159,6 +159,11 @@ void Application::RunEventLoop(void) const
#endif /* _DEBUG */
}
void Application::OnShutdown(void)
{
/* Nothing to do here. */
}
/**
* Watches for changes to the system time. Adjusts timers if necessary.
*/

View File

@ -101,7 +101,7 @@ protected:
void RunEventLoop(void) const;
virtual void OnShutdown(void) = 0;
virtual void OnShutdown(void);
private:
static Application *m_Instance; /**< The application instance. */

40
lib/hello/CMakeLists.txt Normal file
View File

@ -0,0 +1,40 @@
# Icinga 2
# Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
mkclass_target(hello.ti hello.th)
mkembedconfig_target(hello-type.conf hello-type.cpp)
add_library(hello SHARED
hello.cpp hello.th hello-type.cpp
)
target_link_libraries(hello ${Boost_LIBRARIES} base)
set_target_properties (
hello PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
FOLDER Lib
)
install(
TARGETS hello
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
)

21
lib/hello/hello-type.conf Normal file
View File

@ -0,0 +1,21 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
type Hello {
}

38
lib/hello/hello.cpp Normal file
View File

@ -0,0 +1,38 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "hello/hello.h"
#include "base/dynamictype.h"
#include "base/logger_fwd.h"
using namespace icinga;
REGISTER_TYPE(Hello);
/**
* The entry point for the Hello application.
*
* @returns An exit status.
*/
int Hello::Main(void)
{
Log(LogInformation, "hello", "Hello World!");
return 0;
}

44
lib/hello/hello.h Normal file
View File

@ -0,0 +1,44 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef HELLO_H
#define HELLO_H
#include "hello/hello.th"
namespace icinga
{
/**
* The Hello application.
*
* @ingroup hello
*/
class Hello : public ReflectionObjectImpl<Hello>
{
public:
DECLARE_PTR_TYPEDEFS(Hello);
DECLARE_TYPENAME(Hello);
int Main(void);
};
}
#endif /* HELLO_H */

10
lib/hello/hello.ti Normal file
View File

@ -0,0 +1,10 @@
#include "base/application.h"
namespace icinga
{
class Hello : Application
{
};
}

View File

@ -38,8 +38,6 @@ INITIALIZE_ONCE(IcingaApplication, &IcingaApplication::StaticInitialize);
void IcingaApplication::StaticInitialize(void)
{
(void) Utility::LoadExtensionLibrary("methods");
ScriptVariable::Set("IcingaEnableNotifications", true);
ScriptVariable::Set("IcingaEnableEventHandlers", true);
ScriptVariable::Set("IcingaEnableFlapping", true);