Delete cherokee-1.2.104.patchset

This commit is contained in:
waddlesplash
2020-04-10 10:41:07 -04:00
committed by GitHub
parent 28632dba72
commit 0d1d1b36bb

View File

@@ -1,836 +0,0 @@
From 80027ac878872e0e7338e2e36825d8ca34a17f36 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Fri, 12 May 2017 08:50:44 +0200
Subject: import patch from previous version, fix -lnetwork check
diff --git a/configure.ac b/configure.ac
index 9ea50b2..a77cd32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,6 +108,9 @@ AC_MSG_CHECKING([host platform characteristics])
*-*-hpux*)
libdl="-ldl"
;;
+ *-*-haiku*)
+ libdl=""
+ ;;
*-*-aix*)
libdl="-ldl"
;;
@@ -314,6 +317,8 @@ AC_CHECK_FUNC(socket, :, [
AC_CHECK_LIB(nsl, main)
AC_CHECK_LIB(inet, socket)
AC_CHECK_LIB(gen, main)
+# Check for Haiku libnetwork
+ AC_CHECK_LIB(network, socket)
])
AC_SEARCH_LIBS(accept, socket)
@@ -426,6 +431,7 @@ dnl
AC_SEARCH_LIBS(inet_pton, [socket nsl resolv])
AC_CHECK_FUNCS(inet_pton inet_ntop inet_addr)
+AC_SEARCH_LIBS(gethostbyname, nsl network)
AC_SEARCH_LIBS(gethostbyname, [socket nsl resolv])
AC_CHECK_FUNCS(gethostbyname gethostbyname_r)
--
2.7.0
From 2539b4957dfb5bf782862713062eca24b5a540c0 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Wed, 23 Oct 2013 09:29:05 +0100
Subject: Updated python script to look for python2 in shebang line.
diff --git a/po/admin/generate_POTFILESin.py b/po/admin/generate_POTFILESin.py
index c585bd6..e499d53 100755
--- a/po/admin/generate_POTFILESin.py
+++ b/po/admin/generate_POTFILESin.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python2
# Cherokee POTFILES.in generator
#
--
1.8.3.4
From 38e8c91fc695a6bedc82614a710f4ea146cc57e6 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Wed, 23 Oct 2013 11:57:16 +0100
Subject: Modified autogen.sh to avoid trying to symlink python2.
diff --git a/autogen.sh b/autogen.sh
index 7418013..fe0ca9e 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -83,24 +83,25 @@ hash python2 2>&- || {
PYTHON2EXISTS=true
PYTHON2BIN=$(which $python2)
- prompt=$(echo -n "Create symlink from $PYTHON2BIN to /usr/local/bin/python2? [Yes|no] ")
+ # Avoid this code for Haiku.
+ #prompt=$(echo -n "Create symlink from $PYTHON2BIN to /usr/local/bin/python2? [Yes|no] ")
- read -p "$prompt" CREATESYMLINK
- CREATESYMLINK=${CREATESYMLINK:-no}
-
- if [ "$CREATESYMLINK" = "Yes" ] || [ "$CREATESYMLINK" = "yes" ] || [ "$CREATESYMLINK" = "Y" ] || [ "$CREATESYMLINK" = "y" ]
- then
- echo "Symlinking $PYTHON2BIN to /usr/local/bin/python2"
- ln -s $PYTHON2BIN /usr/local/bin/python2
- else
- echo ""
- echo "Exiting:"
- echo " A python2 symlink to a Python 2.x binary (e.g. $PYTHON2BIN) is required to continue."
- echo " Please use a Python installation script of your choice that will create the required"
- echo " symlink or manually create a symlink in a location accessible from your \$PATH environment"
- echo " variable and then rerun this script."
- DIE=1
- fi
+ #read -p "$prompt" CREATESYMLINK
+ #CREATESYMLINK=${CREATESYMLINK:-no}
+
+ #if [ "$CREATESYMLINK" = "Yes" ] || [ "$CREATESYMLINK" = "yes" ] || [ "$CREATESYMLINK" = "Y" ] || [ "$CREATESYMLINK" = "y" ]
+ #then
+ # echo "Symlinking $PYTHON2BIN to /usr/local/bin/python2"
+ # ln -s $PYTHON2BIN /usr/local/bin/python2
+ #else
+ # echo ""
+ # echo "Exiting:"
+ # echo " A python2 symlink to a Python 2.x binary (e.g. $PYTHON2BIN) is required to continue."
+ # echo " Please use a Python installation script of your choice that will create the required"
+ # echo " symlink or manually create a symlink in a location accessible from your \$PATH environment"
+ # echo " variable and then rerun this script."
+ # DIE=1
+ #fi
break
else
echo " NOT found."
--
1.8.3.4
From ce8fda6b4af48291c6158f4b5192fc31f8d39e6e Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Wed, 23 Oct 2013 17:28:26 +0100
Subject: Look for the proper python binary. Look in the right place for env
binary.
diff --git a/cherokee/main_admin.c b/cherokee/main_admin.c
index f072bf9..b4804d0 100644
--- a/cherokee/main_admin.c
+++ b/cherokee/main_admin.c
@@ -554,14 +554,22 @@ check_for_python (void)
int re;
pid_t pid;
int exitcode = -1;
+#ifndef __HAIKU__
char const *args[] = {"env", "python2", "-c", "raise SystemExit", NULL};
+#else
+ char const *args[] = {"env", "python2", "-c", "raise SystemExit", NULL};
+#endif
pid = fork();
if (pid == -1) {
return ret_error;
} else if (pid == 0) {
+#ifndef __HAIKU__
execv ("/usr/bin/env", (char * const *) args);
+#else
+ execv ("/bin/env", (char * const *) args);
+#endif
} else {
do {
--
1.8.3.4
From c66cd7b18aa1f5075bbf2bd604f03bc6e8c651b9 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Wed, 23 Oct 2013 17:53:15 +0100
Subject: Use Haiku paths to look for cherokee and cherokee-worker binaries.
diff --git a/constants.h.pre b/constants.h.pre
index de1cb72..c85fce1 100644
--- a/constants.h.pre
+++ b/constants.h.pre
@@ -14,8 +14,15 @@
# define CHEROKEE_RRD_DIR "%localstatedir%/lib/cherokee/graphs"
# define CHEROKEE_CONFDIR "%sysconfdir%/cherokee"
-# define CHEROKEE_SERVER "%prefix%/sbin/cherokee"
-# define CHEROKEE_WORKER "%prefix%/sbin/cherokee-worker"
+
+#ifndef __HAIKU__
+ # define CHEROKEE_SERVER "%prefix%/sbin/cherokee"
+ # define CHEROKEE_WORKER "%prefix%/sbin/cherokee-worker"
+#else
+ # define CHEROKEE_SERVER "%prefix%/bin/x86/cherokee"
+ # define CHEROKEE_WORKER "%prefix%/bin/x86/cherokee-worker"
+#endif
+
# define CHEROKEE_ICONSDIR "%prefix%/share/cherokee/icons"
# define CHEROKEE_THEMEDIR "%prefix%/share/cherokee/themes"
# define CHEROKEE_PANIC_PATH "%prefix%/bin/cherokee-panic"
--
1.8.3.4
From d60e150b9d8fbe02a7f66f22d706fcaa8540c1e0 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Wed, 23 Oct 2013 18:22:26 +0100
Subject: Look for binaries in the proper location for Haiku.
diff --git a/admin/configured.py.pre b/admin/configured.py.pre
index 009f24a..2b3b744 100644
--- a/admin/configured.py.pre
+++ b/admin/configured.py.pre
@@ -10,8 +10,8 @@ SYSCONFDIR = "%sysconfdir%"
LOCALSTATE = "%localstatedir%"
VERSION = "%version%"
-CHEROKEE_SERVER = join (PREFIX, "sbin/cherokee")
-CHEROKEE_WORKER = join (PREFIX, "sbin/cherokee-worker")
+CHEROKEE_SERVER = join (PREFIX, "bin/x86/cherokee")
+CHEROKEE_WORKER = join (PREFIX, "bin/x86/cherokee-worker")
CHEROKEE_ADMINDIR = join (PREFIX, "share/cherokee/admin")
CHEROKEE_ICONSDIR = join (PREFIX, "share/cherokee/icons")
CHEROKEE_THEMEDIR = join (PREFIX, "share/cherokee/themes")
--
1.8.3.4
From 15288467785f8e093973e936b69640fcf461a92f Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Wed, 23 Oct 2013 18:59:30 +0100
Subject: Updated paths for Haiku.
diff --git a/admin/configured.py.pre b/admin/configured.py.pre
index 2b3b744..174b1b3 100644
--- a/admin/configured.py.pre
+++ b/admin/configured.py.pre
@@ -10,12 +10,12 @@ SYSCONFDIR = "%sysconfdir%"
LOCALSTATE = "%localstatedir%"
VERSION = "%version%"
-CHEROKEE_SERVER = join (PREFIX, "bin/x86/cherokee")
-CHEROKEE_WORKER = join (PREFIX, "bin/x86/cherokee-worker")
-CHEROKEE_ADMINDIR = join (PREFIX, "share/cherokee/admin")
-CHEROKEE_ICONSDIR = join (PREFIX, "share/cherokee/icons")
-CHEROKEE_THEMEDIR = join (PREFIX, "share/cherokee/themes")
-CHEROKEE_PANIC_PATH = join (PREFIX, "bin/cherokee-panic")
+CHEROKEE_SERVER = join (PREFIX, "bin/cherokee-x86")
+CHEROKEE_WORKER = join (PREFIX, "bin/cherokee-worker-x86")
+CHEROKEE_ADMINDIR = join (DATADIR, "cherokee/admin")
+CHEROKEE_ICONSDIR = join (DATADIR, "cherokee/icons")
+CHEROKEE_THEMEDIR = join (DATADIR, "cherokee/themes")
+CHEROKEE_PANIC_PATH = join (PREFIX, "bin/cherokee-panic-x86")
CHEROKEE_PLUGINDIR = join (LIBDIR, "cherokee")
CHEROKEE_DATADIR = join (DATADIR, "cherokee")
CHEROKEE_DEPSDIR = join (DATADIR, "cherokee/deps")
diff --git a/constants.h.pre b/constants.h.pre
index c85fce1..0c21e80 100644
--- a/constants.h.pre
+++ b/constants.h.pre
@@ -15,16 +15,11 @@
# define CHEROKEE_CONFDIR "%sysconfdir%/cherokee"
-#ifndef __HAIKU__
- # define CHEROKEE_SERVER "%prefix%/sbin/cherokee"
- # define CHEROKEE_WORKER "%prefix%/sbin/cherokee-worker"
-#else
- # define CHEROKEE_SERVER "%prefix%/bin/x86/cherokee"
- # define CHEROKEE_WORKER "%prefix%/bin/x86/cherokee-worker"
-#endif
+# define CHEROKEE_SERVER "%prefix%/bin/cherokee-x86"
+# define CHEROKEE_WORKER "%prefix%/bin/cherokee-worker-x86"
-# define CHEROKEE_ICONSDIR "%prefix%/share/cherokee/icons"
-# define CHEROKEE_THEMEDIR "%prefix%/share/cherokee/themes"
-# define CHEROKEE_PANIC_PATH "%prefix%/bin/cherokee-panic"
+# define CHEROKEE_ICONSDIR "%datadir%/cherokee/icons"
+# define CHEROKEE_THEMEDIR "%datadir%/cherokee/themes"
+# define CHEROKEE_PANIC_PATH "%prefix%/bin/cherokee-panic-x86"
#endif
--
1.8.3.4
From 5da89da7b584bbf79dafae32a69a2c2fe7ce4f8b Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 07:53:09 +0100
Subject: Added documentation for Haiku specifics. - Updated README.Haiku with
running information.
diff --git a/README.Haiku b/README.Haiku
new file mode 100644
index 0000000..30d8ff9
--- /dev/null
+++ b/README.Haiku
@@ -0,0 +1,22 @@
+Cherokee for Haiku
+------------------
+
+Building cherokee for Haiku.
+
+- Run in terminal:
+ haikuporter -S cherokee_x86
+- cherokee_x86 will build and package into $TREE_PATH/packages/.
+- Install the package:
+ cp $TREE_PATH/packages/cherokee_x86-1.2.x-1-x86_gcc2.hpkg /boot/system/packages
+
+
+Running cherokee for Haiku.
+
+- If you don't already have a cherokee.conf configuration file, start cherokee-admin to generate one:
+ - Run: cherokee-admin-x86
+ - Login to the interface.
+ - Generate a configuration file via the web UI.
+- If you're upgrading/already have cherokee.conf, you can now start cherokee:
+ - Run: cherokee-x86
+
+Contact: arfonzo in #haiku, IRC Freenode.
--
1.8.3.4
From a6d3794484a0cc702d0e56d2f5f214376317c6f1 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 11:55:02 +0100
Subject: Updated default web page to show Haiku-specific information on next
steps to configure cherokee.
diff --git a/www/index.html b/www/index.html
index 527c1a5..c745913 100644
--- a/www/index.html
+++ b/www/index.html
@@ -42,8 +42,14 @@
<div id="contents">
<div class="message">
<p>This page is used to test the proper operation of the Cherokee Web Server after it has been installed. If you can read this page, it means that the Cherokee Web Server installed at this site is working properly.</p>
-
- <p><strong>Note:</strong> If you see this page after uploading site content you probably have not replaced the <code>index.html</code> file.</p>
+
+ <p><strong>Haiku notes:</strong></p>
+ <ul>
+ <li>If you see this page, cherokee is working but you probably have not configured cherokee via <strong>cherokee-admin</strong> to point to another web document root, or create and edit this file manually.</li>
+ <li>The configuration file is in: <strong>/boot/system/settings/cherokee/cherokee.conf</strong>.</li>
+ <li>The documentation is in: <strong>/boot/system/documentation/packages/</strong>.</li>
+ <li>This default site has <strong>no write permissions</strong> on Haiku: you will not be able to modify it. Please change the website vServer Document Root in cherokee-admin or in the config file manually.</li>
+ </ul>
</div>
</div>
<div class="powered">
--
1.8.3.4
From 9bd63d46cbf2a0ad91fe25bcd5e453e655f93708 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 13:36:52 +0100
Subject: Fix -x86 suffix binary name reference to cherokee-worker-x86. The
snprintf() lines presumes too much about the originating binary name. :|
diff --git a/cherokee/main.c b/cherokee/main.c
index 85d1074..6ef7803 100644
--- a/cherokee/main.c
+++ b/cherokee/main.c
@@ -110,7 +110,11 @@ figure_worker_path (const char *arg0)
if (cherokee_worker == NULL)
goto out;
+#ifndef __HAIKU__
snprintf (cherokee_worker, len, "%s-worker", arg0);
+#else
+ snprintf (cherokee_worker, len, "cherokee-worker-x86", arg0);
+#endif
return;
}
--
1.8.3.4
From 8a8bb0626c7f21053337e83f5b7365c71c5ac788 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 13:49:43 +0100
Subject: Set file descriptor limit, FD_NUM_CUSTOM_LIMIT to 512 on Haiku.
diff --git a/cherokee/macros.h b/cherokee/macros.h
index da2d714..99d905e 100644
--- a/cherokee/macros.h
+++ b/cherokee/macros.h
@@ -113,7 +113,11 @@
#define FD_NUM_MIN_SYSTEM 20 /* range: 16 ... 64 */
#define FD_NUM_MIN_AVAILABLE 8 /* range: 8 ... 65000 */
#define FD_NUM_MIN_PER_THREAD 8 /* range: 8 ... 65000 */
+#ifndef __HAIKU__
#define FD_NUM_CUSTOM_LIMIT 4096 /* range: 16 ... 65000 */
+#else
+#define FD_NUM_CUSTOM_LIMIT 512 /* range: 16 ... 65000 */
+#endif
#define EXIT_OK 0
#define EXIT_ERROR 1
--
1.8.3.4
From 5766b97fae749a956187d34cb757af3823ada1e1 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 16:07:51 +0100
Subject: Updated local state directory to use data directory.
diff --git a/constants.h.pre b/constants.h.pre
index 0c21e80..909b87c 100644
--- a/constants.h.pre
+++ b/constants.h.pre
@@ -9,9 +9,15 @@
# define CHEROKEE_DATADIR "%datadir%/cherokee"
# define CHEROKEE_DOCDIR "%docdir%"
+#ifndef __HAIKU__
# define CHEROKEE_VAR_RUN "%localstatedir%/run"
# define CHEROKEE_FLCACHE "%localstatedir%/lib/cherokee/flcache"
# define CHEROKEE_RRD_DIR "%localstatedir%/lib/cherokee/graphs"
+#else
+# define CHEROKEE_VAR_RUN "%datadir%/run"
+# define CHEROKEE_FLCACHE "%datadir%/lib/cherokee/flcache"
+# define CHEROKEE_RRD_DIR "%datadir%/lib/cherokee/graphs"
+#endif
# define CHEROKEE_CONFDIR "%sysconfdir%/cherokee"
--
1.8.3.4
From 7827ae1bc8792d32bc6644db16ca42927834db32 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 16:27:14 +0100
Subject: Update paths for Haiku.
diff --git a/constants.h.pre b/constants.h.pre
index 909b87c..1169aba 100644
--- a/constants.h.pre
+++ b/constants.h.pre
@@ -9,15 +9,9 @@
# define CHEROKEE_DATADIR "%datadir%/cherokee"
# define CHEROKEE_DOCDIR "%docdir%"
-#ifndef __HAIKU__
-# define CHEROKEE_VAR_RUN "%localstatedir%/run"
-# define CHEROKEE_FLCACHE "%localstatedir%/lib/cherokee/flcache"
-# define CHEROKEE_RRD_DIR "%localstatedir%/lib/cherokee/graphs"
-#else
# define CHEROKEE_VAR_RUN "%datadir%/run"
# define CHEROKEE_FLCACHE "%datadir%/lib/cherokee/flcache"
# define CHEROKEE_RRD_DIR "%datadir%/lib/cherokee/graphs"
-#endif
# define CHEROKEE_CONFDIR "%sysconfdir%/cherokee"
--
1.8.3.4
From fc7cf8a2e392b6b0658b3f47a20cfe06b5d11d02 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 14:23:06 +0100
Subject: Override 'ps' behavior for Haiku in python scripts.
diff --git a/admin/Cherokee.py b/admin/Cherokee.py
index ac76692..2ca3d56 100644
--- a/admin/Cherokee.py
+++ b/admin/Cherokee.py
@@ -85,8 +85,10 @@ class PID:
except: pass
def _figure_pid (self):
- # Execture ps
- ret = popen.popen_sync ("ps aux")
+ # Execute ps
+ # TODO: Haiku fix.
+ #ret = popen.popen_sync ("ps aux")
+ ret = popen.popen_sync ("ps")
ps = ret['stdout']
# Try to find the Cherokee process
@@ -260,6 +262,7 @@ admin = Admin()
# Helper functions
#
def _pid_is_alive (pid):
+ # TODO: Haiku fix.
if not pid:
return False
--
1.8.3.4
From 10af6f5c149c7f6dad49c9f4b756db3c937c37bd Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 15:38:56 +0100
Subject: For stopping cherokee: use level 9 instead of SIGTERM.
diff --git a/admin/Cherokee.py b/admin/Cherokee.py
index 2ca3d56..4d07ba1 100644
--- a/admin/Cherokee.py
+++ b/admin/Cherokee.py
@@ -283,7 +283,8 @@ def _pid_is_alive (pid):
def _pid_kill (pid):
# Kill it
try:
- os.kill (pid, signal.SIGTERM)
+ #os.kill (pid, signal.SIGTERM)
+ os.kill (pid, 9)
except:
return not _pid_is_alive(pid)
--
1.8.3.4
From 663f9e0765a7f1b0800d541793530f4853cd8776 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Thu, 24 Oct 2013 14:46:56 +0100
Subject: Haiku-specific code to terminate multiple processes (WIP). -
Currently need to hit "Stop" button on cherokee-admin three times to
terminate all cherokee processes.
diff --git a/admin/Cherokee.py b/admin/Cherokee.py
index 4d07ba1..109e39d 100644
--- a/admin/Cherokee.py
+++ b/admin/Cherokee.py
@@ -70,43 +70,72 @@ class PID:
def _read_pid_file (self):
# Check the configuration
- self._pid_file = CTK.cfg.get_val("server!pid_file")
- if not self._pid_file:
- return
+ #self._pid_file = CTK.cfg.get_val("server!pid_file")
+ #if not self._pid_file:
+ # return
# Read the file
- try:
- f = open(self._pid_file, 'r')
- except: return
+ #try:
+ # f = open(self._pid_file, 'r')
+ #except: return
- self.pid = int(f.readline())
+ #self.pid = int(f.readline())
- try: f.close()
- except: pass
+ #try: f.close()
+ #except: pass
+
+ self._figure_pid()
def _figure_pid (self):
# Execute ps
- # TODO: Haiku fix.
+ # Haiku fix.
#ret = popen.popen_sync ("ps aux")
ret = popen.popen_sync ("ps")
ps = ret['stdout']
# Try to find the Cherokee process
for l in ps.split("\n"):
- if "cherokee " in l and "-C %s"%(CTK.cfg.file) in l:
+ #if "cherokee " in l and "-C %s"%(CTK.cfg.file) in l:
+ if "cherokee-x " in l or "cherokee-x8 " in l or "cherokee-x86 " in l or ("cherokee" in l and "--admin_c" in l):
pid = filter (lambda x: x.isdigit(), l.split())[0]
self.pid = int(pid)
-
class Server:
def is_alive (self):
return _pid_is_alive (pid.pid)
def stop (self):
if not pid.pid: return
-
+
+ # TODO: We should find three PIDs and kill them on Haiku.
+
# Kill the process
return _pid_kill(pid.pid)
+
+ #def stop_haiku (self):
+ #if not pid.pid: return
+
+ ## TODO: kill as many pids as we can find for Haiku.
+ #more_pids = True
+
+ #while (more_pids):
+
+ # if _pid_kill(pid.pid):
+
+ # last_pid = pid.pid
+ # pid._figure_pid()
+
+ # if (last_pid == pid.pid):
+ # more_pids = False
+
+ # else:
+ # return False
+
+ #if not more_pids:
+ # return True
+ #else:
+ # return False
+
def restart (self, graceful=True):
if not pid.pid: return
--
1.8.3.4
From 247b7aa1c553e3e48a900ef446a0e8c4805156b2 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Fri, 25 Oct 2013 13:02:58 +0100
Subject: =?UTF-8?q?Fix=20stop=20service=20button=20on=20cherokee-admin.=0A?=
=?UTF-8?q?-=20Thanks=20to=20jimi=20for=20help=20with=20=5Fpid=5Fkill().?=
diff --git a/admin/Cherokee.py b/admin/Cherokee.py
index 109e39d..1e218e8 100644
--- a/admin/Cherokee.py
+++ b/admin/Cherokee.py
@@ -30,6 +30,8 @@ import time
import errno
import fcntl
import signal
+# For Haiku process control.
+import re
from subprocess import *
from select import select
@@ -309,6 +311,7 @@ def _pid_is_alive (pid):
return True
+"""
def _pid_kill (pid):
# Kill it
try:
@@ -331,3 +334,16 @@ def _pid_kill (pid):
# Did not succeed
return False
+"""
+
+def _pid_kill (pid):
+ p = Popen('ps', stdout=PIPE)
+ out, err = p.communicate()
+ for line in out.splitlines():
+ line = str(line)
+ if 'cherokee-x86 ' in line or 'cherokee-worker-x86 ' in line:
+ id = re.split(' *', line)[-4]
+ pid = int(id)
+ os.kill(pid, signal.SIGKILL)
+
+ return True
--
1.8.3.4
From 5a23dc66ca18cfe6e7b643e5b6dba495b66ff073 Mon Sep 17 00:00:00 2001
From: "Arfonzo J. Coward" <art@poorcoding.com>
Date: Fri, 25 Oct 2013 15:51:28 +0100
Subject: Begin work on Haiku-specific _stats object.
diff --git a/admin/SystemStats.py b/admin/SystemStats.py
index 2f93e5c..25be53f 100644
--- a/admin/SystemStats.py
+++ b/admin/SystemStats.py
@@ -39,16 +39,19 @@ def get_system_stats():
global _stats
if not _stats:
- if sys.platform.startswith('linux'):
+ if sys.platform.startswith('linux'):
_stats = System_stats__Linux()
elif sys.platform == 'darwin':
_stats = System_stats__Darwin()
elif sys.platform.startswith ('freebsd'):
_stats = System_stats__FreeBSD()
- elif sys.platform.startswith ('openbsd'):
+ elif sys.platform.startswith ('openbsd'):
_stats = System_stats__OpenBSD()
elif sys.platform.startswith ('sunos'):
_stats = System_stats__Solaris()
+ elif sys.platform.startswith ('haiku'):
+ #_stats = System_stats__Haiku()
+ _stats = System_stats()
else:
_stats = System_stats()
@@ -80,6 +83,135 @@ class System_stats:
self.hostname = ''
+# Haiku implementation.
+class System_stats__Haiku (Thread, System_stats):
+ CHECK_INTERVAL = 2
+
+ def __init__ (self):
+ Thread.__init__ (self)
+ System_stats.__init__ (self)
+ self.daemon = True
+
+ self.cpu._user_prev = 0
+ self.cpu._sys_prev = 0
+ self.cpu._nice_prev = 0
+ self.cpu._idle_prev = 0
+
+ # Read valid values
+ self._read_hostname()
+ self._read_cpu()
+ self._read_memory()
+ self._read_cpu_info()
+
+ self.start()
+
+ def _read_hostname (self):
+ # Read /etc/hostname
+ if os.access ("/etc/hostname", os.R_OK):
+ fd = open ("/etc/hostname", 'r')
+ self.hostname = fd.readline().strip()
+ fd.close()
+ return
+
+ # Execute /bin/hostname
+ ret = popen.popen_sync ("/bin/hostname")
+ self.hostname = ret['stdout'].split('\n')[0].strip()
+
+ def _read_cpu_info (self):
+ fd = open("/proc/cpuinfo", 'r')
+ tmp = fd.read()
+ fd.close()
+
+ # Cores
+ cores = re.findall(r'cpu cores.+?(\d+)\n', tmp)
+ if cores:
+ self.cpu.cores = cores[0]
+
+ # Processors
+ processors = re.findall (r'processor.+?:.+?(\d+)\n', tmp, re.I)
+ if processors:
+ self.cpu.num = str (len(processors))
+ else:
+ processors = re.findall (r'Processor[\t ]+:', tmp, re.I)
+ self.cpu.num = str (len(processors))
+
+ # Speed
+ hz = re.findall (r'model name.+?([\d. ]+GHz)\n', tmp)
+ if not hz:
+ hz = re.findall (r'model name.+?([\d. ]+MHz)\n', tmp)
+ if not hz:
+ hz = re.findall (r'model name.+?([\d. ]+THz)\n', tmp)
+
+ if hz:
+ self.cpu.speed = hz[0]
+ else:
+ mhzs = re.findall (r'cpu MHz.+?([\d.]+)\n', tmp)
+ if mhzs:
+ self.cpu.speed = '%s MHz' %(' + '.join(mhzs))
+
+ if self.cpu.speed:
+ return
+
+ # Last option: BogoMIPS
+ bogomips = re.findall (r'BogoMIPS[\t ]+:[\t ]+(\d+)', tmp)
+ if bogomips:
+ self.cpu.speed = '%s BogoMIPS' %(bogomips[0])
+
+ def _read_cpu (self):
+ fd = open("/proc/stat", 'r')
+ fields = fd.readline().split()
+ fd.close()
+
+ user = float(fields[1])
+ sys = float(fields[2])
+ nice = float(fields[3])
+ idle = float(fields[4])
+
+ total = ((user - self.cpu._user_prev) + (sys - self.cpu._sys_prev) + (nice - self.cpu._nice_prev) + (idle - self.cpu._idle_prev))
+ self.cpu.usage = int(100.0 * ((user + sys + nice) - (self.cpu._user_prev + self.cpu._sys_prev + self.cpu._nice_prev)) / (total + 0.001) + 0.5)
+
+ if (self.cpu.usage > 100):
+ self.cpu.usage = 100
+
+ self.cpu.idle = 100 - self.cpu.usage
+
+ self.cpu._user_prev = user
+ self.cpu._sys_prev = sys
+ self.cpu._nice_prev = nice
+ self.cpu._idle_prev = idle
+
+ def _read_memory (self):
+ fd = open("/proc/meminfo", "r")
+ lines = fd.readlines()
+ fd.close()
+
+ total = 0
+ used = 0
+ cached = 0
+ buffers = 0
+
+ for line in lines:
+ parts = line.split()
+ if parts[0] == 'MemTotal:':
+ total = int(parts[1])
+ elif parts[0] == 'MemFree:':
+ used = int(parts[1])
+ elif parts[0] == 'Cached:':
+ cached = int(parts[1])
+ elif parts[0] == 'Buffers:':
+ buffers = int(parts[1])
+
+ self.mem.total = total
+ self.mem.used = total - (used + cached + buffers)
+ self.mem.free = total - self.mem.used
+
+ def run (self):
+ while True:
+ self._read_cpu()
+ self._read_memory()
+ time.sleep (self.CHECK_INTERVAL)
+
+
# MacOS X implementation
class System_stats__Darwin (Thread, System_stats):
CHECK_INTERVAL = 2
--
1.8.3.4