Skip to content

Commit

Permalink
Merge pull request #95 from dterweij/6.1.x
Browse files Browse the repository at this point in the history
Improvement of Scavenge part 2.
  • Loading branch information
dterweij committed Feb 21, 2014
2 parents 18af5df + ae74d11 commit ea28750
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 143 deletions.
29 changes: 18 additions & 11 deletions kloxo/bin/common/clearsession.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<?php

// Kloxo, Hosting Control Panel
//
// Copyright (C) 2000-2009 LxLabs
// Copyright (C) 2009-2014 LxCenter
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
include_once 'htmllib/lib/displayinclude.php';

function clearsession_main()
Expand Down Expand Up @@ -34,13 +51,3 @@ function clearsession_main()
}

clearsession_main();

// I do not want to wait for 600 secs in debug mode :)
// Altho why is there a sleep at all....
if ($sgbl->dbg >= 0) {
dprint("Sleeping for 10 seconds....\n");
sleep(10);
} else {
dprint("Sleeping for 600 seconds....\n");
sleep(600);
}
51 changes: 33 additions & 18 deletions kloxo/bin/common/function.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#!/bin/sh

# issue #623

# Kloxo, Hosting Control Panel
#
# Copyright (C) 2000-2009 LxLabs
# Copyright (C) 2009-2014 LxCenter
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is loaded from kloxo-wrapper.sh
#
__path_php_path="/usr/local/lxlabs/ext/php/php";
__path_program_root="/usr/local/lxlabs/$progname/";
__path_slave_db="/usr/local/lxlabs/$progname/etc/conf/slave-db.db";

# __path_server_path="../sbin/$progname.php";
# __path_server_exe="../sbin/$progname.exe";
# __path_low_memory_file="../etc/flag/lowmem.flag";
__path_program_root="/usr/local/lxlabs/kloxo";
__path_slave_db="/usr/local/lxlabs/kloxo/etc/conf/slave-db.db";

__path_server_path="/usr/local/lxlabs/kloxo/sbin/$progname.php";
__path_server_exe="/usr/local/lxlabs/kloxo/sbin/$progname.exe";
__path_server_path="/usr/local/lxlabs/kloxo/sbin/kloxo.php";
__path_server_exe="/usr/local/lxlabs/kloxo/sbin/kloxo.exe";
__path_low_memory_file="/usr/local/lxlabs/kloxo/etc/flag/lowmem.flag";

kill_and_save_pid() {
Expand All @@ -22,14 +35,14 @@ kill_and_save_pid() {
}

save_pid() {
echo $$ > "$__path_program_root/pid/$name.pid";
echo $$ > "$__path_program_root/pid/kloxo.pid";
}

kill_pid() {
name=$1
pid=`cat $__path_program_root/pid/$name.pid`;
pid=`cat $__path_program_root/pid/kloxo.pid`;
kill $pid 2>/dev/null
usleep 10000
usleep 1000
kill -9 $pid 2>/dev/null
}

Expand All @@ -47,10 +60,12 @@ wrapper_main() {
while : ; do

if [ -f $__path_low_memory_file ] ; then
/bin/cp $__path_server_exe.core $__path_server_exe
chmod 755 $__path_server_exe
$__path_server_exe $string >/dev/null 2>&1
else
/bin/cp $__path_server_exe.core $__path_server_exe;
chmod 755 $__path_server_exe;
echo "Starting Kloxo core (lowmem)"
$__path_server_exe $string >/dev/null 2>&1;
else
echo "Starting Kloxo core"
$__path_php_path $__path_server_path $string >/dev/null 2>&1;
fi
sleep 10;
Expand Down
9 changes: 6 additions & 3 deletions kloxo/bin/scavenge.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function scavenge_main()
{
global $gbl, $sgbl, $login, $ghtml;

log_scavenge("Fix log dir");
passthru("$sgbl->__path_php_path ../bin/common/fixlogdir.php");

log_scavenge("### Starting Scavenge");
initProgramlib('admin');
uploadStatsLxCenter();
Expand Down Expand Up @@ -60,9 +63,6 @@ function scavenge_main()
system("service lighttpd restart");
}

log_scavenge("Fix log dir");
passthru("$sgbl->__path_php_path ../bin/common/fixlogdir.php");

log_scavenge("InstallApp update");
passthru("$sgbl->__path_php_path ../bin/installapp-update.phps");

Expand All @@ -82,6 +82,9 @@ function scavenge_main()
auto_update();

log_scavenge("### End Scavenge");

// Wait at least 60 seconds before ending the scavenge
sleep(60);
}

exit_if_secondary_master();
Expand Down
69 changes: 39 additions & 30 deletions kloxo/bin/sisinfoc.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
<?php
<?php
// Kloxo, Hosting Control Panel
//
// Copyright (C) 2000-2009 LxLabs
// Copyright (C) 2009-2014 LxCenter
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
include_once "htmllib/lib/include.php";
include_once "htmllib/lib/lxguardincludelib.php";


function collect_traffic()
{
$flfile = "__path_program_etc/last_sisinfoc";
$ret = lfile_get_unserialize($flfile);
$ret['time'] = time();
lfile_put_serialize($flfile, $ret);
}

$global_dontlogshell = true;

exit_if_secondary_master();
exit_if_another_instance_running();
debug_for_backend();

exit_if_another_instance_running();

debug_for_backend();

watchdog__sync::watchRun();


if ($sgbl->is_this_master()) {
$gbl->is_master = true;
initProgram('admin');
run_mail_to_ticket();
$gbl->is_master = true;
initProgram('admin');
run_mail_to_ticket();
}


monitor_load();
collect_traffic();
lxguard_main();
add_to_log("/var/log/kloxo/smtp.log");
add_to_log("/var/log/kloxo/courier");

collect_traffic();

lxguard_main();

function collect_traffic()
{
$flfile = "__path_program_etc/last_sisinfoc";
$ret = lfile_get_unserialize($flfile);
$interval = 20 * 60;
//$interval = 2;
if ((time() - $ret['time']) < $interval) {
//return;
}
$oldtime = $ret['time'];
//if (!$oldtime) { $oldtime = time() - 20 * 60 ; }
if (!$oldtime) { $oldtime = time() - 5 * 60 ; }
$newtime = time();
$ret['time'] = time();
lfile_put_serialize($flfile, $ret);
add_to_log("/var/log/kloxo/smtp.log");

//mailtraffic:generateGraph($oldtime, $newtime);
//webtraffic::generateGraph($oldtime, $newtime);
}
add_to_log("/var/log/kloxo/courier");

Loading

0 comments on commit ea28750

Please sign in to comment.