Skip to content

Commit bb145f8

Browse files
committed
Initial commit
0 parents  commit bb145f8

File tree

9 files changed

+486
-0
lines changed

9 files changed

+486
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*~
2+
*.o
3+
Makefile.in
4+
aclocal.m4
5+
autom4te.cache
6+
autoscan.log
7+
config.h.in
8+
configure
9+
depcomp
10+
install-sh
11+
missing

CMakeLists.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
2+
3+
cmake_policy(VERSION 2.6.0)
4+
5+
INCLUDE(CheckIncludeFiles)
6+
INCLUDE(CheckLibraryExists)
7+
INCLUDE(FindPkgConfig)
8+
9+
MACRO(ADD_TARGET_PROPERTIES _target _name _properties)
10+
SET(_properties ${ARGV})
11+
LIST(REMOVE_AT _properties 0)
12+
LIST(REMOVE_AT _properties 0)
13+
GET_TARGET_PROPERTY(_old_properties ${_target} ${_name})
14+
#MESSAGE("adding property to ${_target} ${_name}: ${_properties}")
15+
IF(NOT _old_properties)
16+
# in case it's NOTFOUND
17+
SET(_old_properties)
18+
ELSE(NOT _old_properties)
19+
SET(_old_properties "${_old_properties} ")
20+
ENDIF(NOT _old_properties)
21+
SET_TARGET_PROPERTIES(${_target} PROPERTIES ${_name} "${_old_properties}${_properties}")
22+
ENDMACRO(ADD_TARGET_PROPERTIES)
23+
24+
PROJECT(multiwatch)
25+
SET(PACKAGE_VERSION 1.0.0)
26+
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
27+
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
28+
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
29+
30+
31+
# libev
32+
CHECK_INCLUDE_FILES(ev.h HAVE_EV_H)
33+
IF(HAVE_EV_H)
34+
CHECK_LIBRARY_EXISTS(ev ev_loop "" HAVE_LIBEV)
35+
IF(HAVE_LIBEV)
36+
SET(EV_LIBRARIES ev)
37+
SET(EV_STATIC_LIBRARIES ev;m)
38+
CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_RT)
39+
IF(NEED_RT)
40+
SET(EV_STATIC_LIBRARIES ${EV_STATIC_LIBRARIES} rt)
41+
ENDIF(NEED_RT)
42+
ELSE(HAVE_LIBEV)
43+
MESSAGE(FATAL_ERROR "Couldn't find lib ev")
44+
ENDIF(HAVE_LIBEV)
45+
ELSE(HAVE_EV_H)
46+
MESSAGE(FATAL_ERROR "Couldn't find <ev.h>")
47+
ENDIF(HAVE_EV_H)
48+
49+
# GLIB 2
50+
pkg_check_modules (GLIB2 REQUIRED glib-2.0)
51+
SET(GLIB_INCLUDES ${GLIB2_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS}/glib-2.0/ ${GLIB2_INCLUDE_DIRS}/glib-2.0/include/)
52+
INCLUDE_DIRECTORIES(${GLIB_INCLUDES})
53+
54+
SET(MAIN_SOURCE multiwatch.c)
55+
56+
SET(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
57+
SET(PACKAGE_VERSION ${PACKAGE_VERSION})
58+
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h ESCAPE_QUOTES)
59+
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
60+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
61+
62+
add_executable(multiwatch ${MAIN_SOURCE})
63+
64+
ADD_TARGET_PROPERTIES(multiwatch COMPILE_FLAGS "-std=gnu99 -Wall -g -Wshadow -W -pedantic -fPIC -D_GNU_SOURCE")
65+
66+
# libev
67+
TARGET_LINK_LIBRARIES(multiwatch "${EV_LIBRARIES}")
68+
69+
# GLIB 2
70+
ADD_TARGET_PROPERTIES(multiwatch LINK_FLAGS "${GLIB2_LDFLAGS}")
71+
ADD_TARGET_PROPERTIES(multiwatch COMPILE_FLAGS "${GLIB2_CFLAGS_OTHER}")
72+
73+
INSTALL(TARGETS multiwatch DESTINATION bin)

COPYING

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License
3+
4+
Copyright (c) 2008 Stefan Bühler
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
AM_CFLAGS=$(GLIB_CFLAGS)
3+
multiwatch_LDADD=$(GLIB_LIBS)
4+
5+
EXTRA_DIST=autogen.sh multiwatch.1 CMakeLists.txt config.h.cmake
6+
man1_MANS=multiwatch.1
7+
8+
bin_PROGRAMS=multiwatch
9+
10+
multiwatch_SOURCES=multiwatch.c

autogen.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
# Run this to generate all the initial makefiles, etc.
3+
4+
ACLOCAL=${ACLOCAL:-aclocal}
5+
AUTOHEADER=${AUTOHEADER:-autoheader}
6+
AUTOMAKE=${AUTOMAKE:-automake}
7+
AUTOMAKE_FLAGS="--add-missing --copy"
8+
AUTOCONF=${AUTOCONF:-autoconf}
9+
10+
ARGV0=$0
11+
12+
set -e
13+
14+
15+
run() {
16+
echo "$ARGV0: running \`$@'"
17+
$@
18+
}
19+
20+
run $ACLOCAL $ACLOCAL_FLAGS
21+
run $AUTOHEADER
22+
run $AUTOMAKE $AUTOMAKE_FLAGS
23+
run $AUTOCONF
24+
echo "Now type './configure ...' and 'make' to compile."

config.h.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
CMake autogenerated config.h file. Do not edit!
3+
*/
4+
5+
#define PACKAGE_NAME "${PACKAGE_NAME}"
6+
#define PACKAGE_VERSION "${PACKAGE_VERSION}"

configure.ac

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# -*- Autoconf -*-
2+
# Process this file with autoconf to produce a configure script.
3+
4+
AC_PREREQ(2.61)
5+
AC_INIT([multiwatch], [1.0.0], [])
6+
AC_CONFIG_SRCDIR([multiwatch.c])
7+
AC_CONFIG_HEADER([config.h])
8+
9+
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
10+
11+
# Checks for programs.
12+
AC_PROG_CC
13+
AC_PROG_MAKE_SET
14+
AC_PROG_INSTALL
15+
16+
# Checks for libraries.
17+
18+
# glib-2.0
19+
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16.0, [
20+
AC_DEFINE([HAVE_GLIB_H], [1], [glib.h])
21+
],[AC_MSG_ERROR("glib-2.0 >= 2.16.0 not found")])
22+
23+
# lib ev
24+
AC_CHECK_HEADERS([ev.h], [], [AC_MSG_ERROR("ev.h not found")])
25+
AC_CHECK_LIB([ev], [ev_loop], [
26+
LIBS="-lev ${LIBS}"
27+
AC_DEFINE([HAVE_LIBEV], [1], [ev_loop in -lev])
28+
], [AC_MSG_ERROR("libev not found")])
29+
30+
# Checks for header files.
31+
AC_CHECK_HEADERS([stdlib.h unistd.h], [])
32+
33+
# Checks for typedefs, structures, and compiler characteristics.
34+
AC_TYPE_PID_T
35+
36+
# Checks for library functions.
37+
AC_FUNC_FORK
38+
39+
# check for extra compiler options (warning options)
40+
if test "${GCC}" = "yes"; then
41+
CFLAGS="${CFLAGS} -Wall -W -Wshadow -pedantic -std=gnu99"
42+
fi
43+
44+
AC_ARG_ENABLE(extra-warnings,
45+
AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
46+
[case "${enableval}" in
47+
yes) extrawarnings=true ;;
48+
no) extrawarnings=false ;;
49+
*) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
50+
esac],[extrawarnings=false])
51+
52+
if test x$extrawarnings = xtrue; then
53+
CFLAGS="${CFLAGS} -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wno-pointer-sign -Wcast-align -Winline -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -Wformat-security"
54+
fi
55+
56+
AC_CONFIG_FILES([Makefile])
57+
AC_OUTPUT

multiwatch.1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.TH multiwatch 1 "March 24, 2009"
2+
.SH NAME
3+
multiwatch \- forks and watches multiple instances of a program in the same environment
4+
.SH SYNOPSIS
5+
.B multiwatch
6+
[options] -- <application> [app arguments]
7+
8+
.B multiwatch
9+
\-v
10+
11+
.B multiwatch
12+
\-\-help | \-?
13+
.SH DESCRIPTION
14+
\fImultiwatch\fP is used to fork and watch multiple fastcgi backends.
15+
.SH OPTIONS
16+
.TP 8
17+
.B \-f, \-\-forks=childs
18+
Number of childs to fork and watch(default 1)
19+
.TP 8
20+
.B \-r, --retry=retries
21+
Number of retries to fork a single child
22+
.TP 8
23+
.B \-t, --timeout=msecs
24+
Retry timeout in ms; if the child dies after the timeout the retry counter is reset
25+
.TP 8
26+
.B \-?, --help
27+
General usage instructions
28+
.TP 8
29+
.B \-v, --version
30+
Show version
31+
.SH EXAMPLE
32+
.TP 8
33+
Spawn 2 rails instances on the same fastcgi socket (and supervise them):
34+
.RS 8
35+
.B spawn-fcgi -s /tmp/fastcgi-php.sock -C 0 -n /usr/bin/multiwatch -f 2 /home/rails/public/dispatch.fcgi
36+
.RE
37+
.SH SEE ALSO
38+
spawn-fcgi(1)
39+
.SH AUTHOR
40+
Stefan Buehler <stbuehler@web.de>.

0 commit comments

Comments
 (0)