Skip to content

Commit

Permalink
Merge pull request #35 from jfsmig/M-cleanup
Browse files Browse the repository at this point in the history
Do not require libevent anymore
  • Loading branch information
jfsmig authored Oct 10, 2018
2 parents ce3b8e6 + 559c367 commit 6966829
Show file tree
Hide file tree
Showing 56 changed files with 7,269 additions and 946 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ dist: trusty
language: c
install:
- sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse"
- curl http://mirror.openio.io/pub/repo/openio/APT-GPG-KEY-OPENIO-0 | sudo apt-key add -
- sudo apt-add-repository "deb http://mirror.openio.io/pub/repo/openio/sds/17.04/ubuntu/trusty ./"
- sudo apt-get update -qq
- sudo apt-get install -y --force-yes libevent-2.0-5 libevent-dev make cmake libglib2.0-dev
- sudo apt-get install -y --force-yes autoconf automake libtool xutils-dev gcc make cmake libglib2.0-dev
env:
matrix:
- BUILD_TYPE=Debug
Expand All @@ -16,5 +14,5 @@ script:
- mkdir /tmp/oio
- export CMAKE_OPTS='-DCMAKE_INSTALL_PREFIX=/tmp/oio -DLD_LIBDIR=lib'
- cmake ${CMAKE_OPTS} -DCMAKE_BUILD_TYPE=$BUILD_TYPE .
- make -j 4 all
- make all
- make install
58 changes: 46 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if (CMAKE_COMPILER_IS_GNUCC)

# gcc >= 4.6
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winline")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wswitch-enum")
Expand Down Expand Up @@ -77,27 +78,60 @@ else()
else()
set (LD_LIBDIR "lib")
endif()
MESSAGE("LD_LIBDIR guessed to ${LD_LIBDIR}")
endif()


find_package(PkgConfig)
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gthread-2.0 gmodule-2.0)
pkg_check_modules(LIBEVENT REQUIRED libevent)

### explicit plugin directory for alerting modules ###

set(GRIDINIT_PLUGINS_DIRECTORY "${LD_LIBDIR}/gridinit")
if(GRIDINIT_PLUGINS)
set(GRIDINIT_PLUGINS_DIRECTORY "${GRIDINIT_PLUGINS}")
endif(GRIDINIT_PLUGINS)
add_custom_target(
libdill_s
ALL
COMMAND ./autogen.sh
COMMAND ./configure --enable-static --disable-shared
COMMAND make
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/vendor/sustrik/libdill
COMMENT "Building libdill")

if (NOT (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}))
add_custom_target(
libdill_source
ALL
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/vendor/sustrik/libdill
COMMAND cd ${CMAKE_BINARY_DIR}/vendor/sustrik/libdill && lndir ${CMAKE_SOURCE_DIR}/vendor/sustrik/libdill
COMMENT "Preparing the source of libdill")
add_dependencies(libdill_s libdill_source)
endif()

set(CMAKE_LIBRARY_PATH "")
set(CMAKE_INCLUDE_PATH "")
include_directories(AFTER ${GLIB2_INCLUDE_DIRS})
include_directories(AFTER
${CMAKE_SOURCE_DIR}/vendor/sustrik/libdill
${GLIB2_INCLUDE_DIRS})

add_definitions(-DLOG_DOMAIN="gridinit")
add_definitions(-DGRIDINIT_DOMAIN="gridinit")

add_subdirectory(./main)

include_directories(BEFORE ${CMAKE_SOURCE_DIR}/main)

add_executable(gridinit
main/gridinit.c
main/children.c
main/limits.c
main/uid.c
main/utils.c)
target_link_libraries(gridinit
${GLIB2_LIBRARIES}
${CMAKE_BINARY_DIR}/vendor/sustrik/libdill/.libs/libdill.a
-pthread -lrt)
add_dependencies(gridinit
libdill_s)


add_executable(gridinit_cmd
main/gridinit_cmd.c
main/format_output.c
main/utils.c)
target_link_libraries(gridinit_cmd ${GLIB2_LIBRARIES})

install(TARGETS gridinit gridinit_cmd
RUNTIME DESTINATION bin)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Gridinit is a tool used to manage non-daemon processes.
### Dependencies

* cmake, make, gcc
* libevent, libevent-devel
* glib, glib-devel
* libdill (currently embedded)

### Compile-time configuration

Expand Down
25 changes: 0 additions & 25 deletions main/CMakeLists.txt

This file was deleted.

11 changes: 0 additions & 11 deletions main/children.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ struct child_s {

static struct child_s SRV_BEACON = {};

static supervisor_postfork_f *supervisor_cb_postfork = NULL;
static void *supervisor_cb_postfork_udata = NULL;

static struct child_s *
supervisor_get_child(const gchar *key)
Expand Down Expand Up @@ -413,8 +411,6 @@ _child_start(struct child_s *sd, void *udata, supervisor_cb_f cb)
case 0: /* child */
setsid();
sd->pid = getpid();
if (supervisor_cb_postfork != NULL)
supervisor_cb_postfork(supervisor_cb_postfork_udata);
reset_sighandler();

/* change the rights before changing the working directory */
Expand Down Expand Up @@ -1174,10 +1170,3 @@ supervisor_children_set_delay_sigkill(const char *key, time_t delay)
return 0;
}

void
supervisor_set_callback_postfork(supervisor_postfork_f *cb, void *udata)
{
supervisor_cb_postfork_udata = udata;
supervisor_cb_postfork = cb;
}

71 changes: 0 additions & 71 deletions main/cnx.c

This file was deleted.

40 changes: 0 additions & 40 deletions main/common.c

This file was deleted.

27 changes: 11 additions & 16 deletions main/gridinit-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define GRID_LOGLVL_WARN (2 << G_LOG_LEVEL_USER_SHIFT)
# define GRID_LOGLVL_ERROR (1 << G_LOG_LEVEL_USER_SHIFT)

# define FATAL(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define ALERT(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define CRIT(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define ERROR(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define WARN(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_WARN, Format, ##__VA_ARGS__)
# define NOTICE(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_NOTICE, Format, ##__VA_ARGS__)
# define INFO(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_INFO, Format, ##__VA_ARGS__)
# define DEBUG(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_DEBUG, Format, ##__VA_ARGS__)
# define TRACE(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_TRACE, Format, ##__VA_ARGS__)

GError* g_error_printf(const char *dom, int code, const char *fmt, ...);
# define FATAL(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define ALERT(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define CRIT(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define ERROR(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
# define WARN(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_WARN, Format, ##__VA_ARGS__)
# define NOTICE(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_NOTICE, Format, ##__VA_ARGS__)
# define INFO(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_INFO, Format, ##__VA_ARGS__)
# define DEBUG(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_DEBUG, Format, ##__VA_ARGS__)
# define TRACE(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_TRACE, Format, ##__VA_ARGS__)

extern time_t supervisor_default_delay_KILL;

extern GQuark gq_log;

/* Children monitoring ----------------------------------------------------- */

enum supervisor_limit_e {
Expand Down Expand Up @@ -86,16 +86,11 @@ struct child_info_s {
gboolean started;
};

typedef void (supervisor_postfork_f) (void *udata);

typedef void (supervisor_cb_f) (void *udata, struct child_info_s *ci);


void supervisor_children_init(void);

/* Sets an optional function that will be used just after the fork */
void supervisor_set_callback_postfork(supervisor_postfork_f *cb, void *udata);

void supervisor_children_fini(void);

guint supervisor_children_cleanall(void);
Expand Down
Loading

0 comments on commit 6966829

Please sign in to comment.