Skip to content

Commit 6966829

Browse files
authored
Merge pull request #35 from jfsmig/M-cleanup
Do not require libevent anymore
2 parents ce3b8e6 + 559c367 commit 6966829

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+7269
-946
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ dist: trusty
33
language: c
44
install:
55
- sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse"
6-
- curl http://mirror.openio.io/pub/repo/openio/APT-GPG-KEY-OPENIO-0 | sudo apt-key add -
7-
- sudo apt-add-repository "deb http://mirror.openio.io/pub/repo/openio/sds/17.04/ubuntu/trusty ./"
86
- sudo apt-get update -qq
9-
- sudo apt-get install -y --force-yes libevent-2.0-5 libevent-dev make cmake libglib2.0-dev
7+
- sudo apt-get install -y --force-yes autoconf automake libtool xutils-dev gcc make cmake libglib2.0-dev
108
env:
119
matrix:
1210
- BUILD_TYPE=Debug
@@ -16,5 +14,5 @@ script:
1614
- mkdir /tmp/oio
1715
- export CMAKE_OPTS='-DCMAKE_INSTALL_PREFIX=/tmp/oio -DLD_LIBDIR=lib'
1816
- cmake ${CMAKE_OPTS} -DCMAKE_BUILD_TYPE=$BUILD_TYPE .
19-
- make -j 4 all
17+
- make all
2018
- make install

CMakeLists.txt

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
3737

3838
# gcc >= 4.6
3939
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
40+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
4041
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winline")
4142
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
4243
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wswitch-enum")
@@ -77,27 +78,60 @@ else()
7778
else()
7879
set (LD_LIBDIR "lib")
7980
endif()
80-
MESSAGE("LD_LIBDIR guessed to ${LD_LIBDIR}")
8181
endif()
8282

8383

8484
find_package(PkgConfig)
8585
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gthread-2.0 gmodule-2.0)
86-
pkg_check_modules(LIBEVENT REQUIRED libevent)
8786

88-
### explicit plugin directory for alerting modules ###
89-
90-
set(GRIDINIT_PLUGINS_DIRECTORY "${LD_LIBDIR}/gridinit")
91-
if(GRIDINIT_PLUGINS)
92-
set(GRIDINIT_PLUGINS_DIRECTORY "${GRIDINIT_PLUGINS}")
93-
endif(GRIDINIT_PLUGINS)
87+
add_custom_target(
88+
libdill_s
89+
ALL
90+
COMMAND ./autogen.sh
91+
COMMAND ./configure --enable-static --disable-shared
92+
COMMAND make
93+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/vendor/sustrik/libdill
94+
COMMENT "Building libdill")
95+
96+
if (NOT (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}))
97+
add_custom_target(
98+
libdill_source
99+
ALL
100+
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/vendor/sustrik/libdill
101+
COMMAND cd ${CMAKE_BINARY_DIR}/vendor/sustrik/libdill && lndir ${CMAKE_SOURCE_DIR}/vendor/sustrik/libdill
102+
COMMENT "Preparing the source of libdill")
103+
add_dependencies(libdill_s libdill_source)
104+
endif()
94105

95106
set(CMAKE_LIBRARY_PATH "")
96107
set(CMAKE_INCLUDE_PATH "")
97-
include_directories(AFTER ${GLIB2_INCLUDE_DIRS})
108+
include_directories(AFTER
109+
${CMAKE_SOURCE_DIR}/vendor/sustrik/libdill
110+
${GLIB2_INCLUDE_DIRS})
98111

99112
add_definitions(-DLOG_DOMAIN="gridinit")
100-
add_definitions(-DGRIDINIT_DOMAIN="gridinit")
101-
102-
add_subdirectory(./main)
103113

114+
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/main)
115+
116+
add_executable(gridinit
117+
main/gridinit.c
118+
main/children.c
119+
main/limits.c
120+
main/uid.c
121+
main/utils.c)
122+
target_link_libraries(gridinit
123+
${GLIB2_LIBRARIES}
124+
${CMAKE_BINARY_DIR}/vendor/sustrik/libdill/.libs/libdill.a
125+
-pthread -lrt)
126+
add_dependencies(gridinit
127+
libdill_s)
128+
129+
130+
add_executable(gridinit_cmd
131+
main/gridinit_cmd.c
132+
main/format_output.c
133+
main/utils.c)
134+
target_link_libraries(gridinit_cmd ${GLIB2_LIBRARIES})
135+
136+
install(TARGETS gridinit gridinit_cmd
137+
RUNTIME DESTINATION bin)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Gridinit is a tool used to manage non-daemon processes.
77
### Dependencies
88

99
* cmake, make, gcc
10-
* libevent, libevent-devel
1110
* glib, glib-devel
11+
* libdill (currently embedded)
1212

1313
### Compile-time configuration
1414

main/CMakeLists.txt

Lines changed: 0 additions & 25 deletions
This file was deleted.

main/children.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ struct child_s {
130130

131131
static struct child_s SRV_BEACON = {};
132132

133-
static supervisor_postfork_f *supervisor_cb_postfork = NULL;
134-
static void *supervisor_cb_postfork_udata = NULL;
135133

136134
static struct child_s *
137135
supervisor_get_child(const gchar *key)
@@ -413,8 +411,6 @@ _child_start(struct child_s *sd, void *udata, supervisor_cb_f cb)
413411
case 0: /* child */
414412
setsid();
415413
sd->pid = getpid();
416-
if (supervisor_cb_postfork != NULL)
417-
supervisor_cb_postfork(supervisor_cb_postfork_udata);
418414
reset_sighandler();
419415

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

1177-
void
1178-
supervisor_set_callback_postfork(supervisor_postfork_f *cb, void *udata)
1179-
{
1180-
supervisor_cb_postfork_udata = udata;
1181-
supervisor_cb_postfork = cb;
1182-
}
1183-

main/cnx.c

Lines changed: 0 additions & 71 deletions
This file was deleted.

main/common.c

Lines changed: 0 additions & 40 deletions
This file was deleted.

main/gridinit-utils.h

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3939
# define GRID_LOGLVL_WARN (2 << G_LOG_LEVEL_USER_SHIFT)
4040
# define GRID_LOGLVL_ERROR (1 << G_LOG_LEVEL_USER_SHIFT)
4141

42-
# define FATAL(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
43-
# define ALERT(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
44-
# define CRIT(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
45-
# define ERROR(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
46-
# define WARN(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_WARN, Format, ##__VA_ARGS__)
47-
# define NOTICE(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_NOTICE, Format, ##__VA_ARGS__)
48-
# define INFO(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_INFO, Format, ##__VA_ARGS__)
49-
# define DEBUG(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_DEBUG, Format, ##__VA_ARGS__)
50-
# define TRACE(Format,...) g_log(GRIDINIT_DOMAIN, GRID_LOGLVL_TRACE, Format, ##__VA_ARGS__)
51-
52-
GError* g_error_printf(const char *dom, int code, const char *fmt, ...);
42+
# define FATAL(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
43+
# define ALERT(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
44+
# define CRIT(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
45+
# define ERROR(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_ERROR, Format, ##__VA_ARGS__)
46+
# define WARN(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_WARN, Format, ##__VA_ARGS__)
47+
# define NOTICE(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_NOTICE, Format, ##__VA_ARGS__)
48+
# define INFO(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_INFO, Format, ##__VA_ARGS__)
49+
# define DEBUG(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_DEBUG, Format, ##__VA_ARGS__)
50+
# define TRACE(Format,...) g_log(LOG_DOMAIN, GRID_LOGLVL_TRACE, Format, ##__VA_ARGS__)
5351

5452
extern time_t supervisor_default_delay_KILL;
5553

54+
extern GQuark gq_log;
55+
5656
/* Children monitoring ----------------------------------------------------- */
5757

5858
enum supervisor_limit_e {
@@ -86,16 +86,11 @@ struct child_info_s {
8686
gboolean started;
8787
};
8888

89-
typedef void (supervisor_postfork_f) (void *udata);
90-
9189
typedef void (supervisor_cb_f) (void *udata, struct child_info_s *ci);
9290

9391

9492
void supervisor_children_init(void);
9593

96-
/* Sets an optional function that will be used just after the fork */
97-
void supervisor_set_callback_postfork(supervisor_postfork_f *cb, void *udata);
98-
9994
void supervisor_children_fini(void);
10095

10196
guint supervisor_children_cleanall(void);

0 commit comments

Comments
 (0)