本文整理汇总了PHP中unix::MEM_TOTAL_INSTALLEE方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::MEM_TOTAL_INSTALLEE方法的具体用法?PHP unix::MEM_TOTAL_INSTALLEE怎么用?PHP unix::MEM_TOTAL_INSTALLEE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::MEM_TOTAL_INSTALLEE方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
function check()
{
$unix = new unix();
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
if ($MEMORY < 624288) {
writelogs(basename(__FILE__) . ":Too low memory, die();", basename(__FILE__), __FILE__, __LINE__);
die;
}
if (!is_file("/usr/bin/ruby1.8")) {
$unix->DEBIAN_INSTALL_PACKAGE("ruby1.8");
}
$EnablePhileSight = GET_INFO_DAEMON("EnablePhileSight");
if ($EnablePhileSight == null) {
$EnablePhileSight = 0;
}
if ($EnablePhileSight == 0) {
writelogs("feature disabled, aborting...", __FUNCTION__, __FILE__, __LINE__);
die;
}
if (system_is_overloaded()) {
writelogs("System overloaded, aborting this feature for the moment", __FUNCTION__, __FILE__, __LINE__);
die;
}
@mkdir("/opt/artica/philesight");
$unix = new unix();
$min = $unix->file_time_min("/opt/artica/philesight/database.db");
$sock = new sockets();
$rr = $sock->GET_INFO("PhileSizeRefreshEach");
if ($rr == null) {
$rr = 120;
}
if ($rr == "disable") {
die;
}
writelogs("/opt/artica/philesight/database.db = {$min} minutes, {$rr} minutes to run", __FUNCTION__, __FILE__, __LINE__);
if ($min >= $rr) {
run();
}
}
示例2: enable_icap
function enable_icap()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
echo basename(__FILE__) . ":Already executed pid {$pid}.. aborting the process\n";
progress("{failed}", 110);
return;
}
$sock = new sockets();
$sock->SET_INFO("kavicapserverEnabled", 1);
$MEM = $unix->MEM_TOTAL_INSTALLEE();
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
$sock->SET_INFO("kavicapserverEnabled", 0);
if ($GLOBALS["OUTPUT"]) {
echo "Not enough memory - {$MEM}\n";
}
progress("{failed}", 110);
return;
}
$q = new mysql_squid_builder();
progress("{verify_icap_center}", 10);
$q->CheckTablesICAP();
if ($q->COUNT_ROWS("c_icap_services") == 0) {
progress("{verify_icap_center} {failed}", 110);
}
progress("{hooking_local_service}", 10);
$q->QUERY_SQL("UPDATE c_icap_services SET `enabled`=1 WHERE ID=6");
if (!$q->ok) {
echo $q->mysql_error . "\n";
progress("{hooking_local_service} {failed}", 110);
}
$q->QUERY_SQL("UPDATE c_icap_services SET `enabled`=1 WHERE ID=5");
if (!$q->ok) {
echo $q->mysql_error . "\n";
progress("{hooking_local_service} {failed}", 110);
}
progress("{reloading} {APP_KAV4PROXY}", 20);
build();
system("/etc/init.d/kav4proxy reload");
progress("{configuring} {APP_SQUID}", 50);
$php = $unix->LOCATE_PHP5_BIN();
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force --noverifcaches");
progress("{restarting} {APP_SQUID}", 70);
system("/etc/init.d/squid restart --force {$GLOBALS["SCRIPT_SUFFIX"]}");
progress("{restarting} Artica-status", 80);
system("/etc/init.d/artica-status restart --force");
progress("{refresh} License", 90);
$GLOBALS["FORCE"] = true;
license_infos(true);
progress("{success} {hooking_local_service}", 100);
}
示例3: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$users = new usersMenus();
$Masterbin = "/usr/local/ArticaStats/bin/postgres";
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, arpd not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} not enough memory\n";
}
if ($unix->process_exists($pid)) {
stop();
}
build_progress_restart("{starting} {failed} no memory", 110);
return;
}
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
build_progress_restart("{starting} {success}", 30);
return true;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$nohup = $unix->find_program("nohup");
$su = $unix->find_program("su");
$rm = $unix->find_program("rm");
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
$EnableInfluxDB = intval($sock->GET_INFO("EnableInfluxDB"));
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} EnableInfluxDB: {$EnableInfluxDB}\n";
}
$InfluxUseRemote = intval($sock->GET_INFO("InfluxUseRemote"));
if ($users->POSTFIX_INSTALLED) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Postfix installed: True\n";
}
}
if ($InfluxUseRemote == 1) {
$EnableInfluxDB = 0;
}
$FreeZePostGres = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/FreeZePostGres"));
if ($FreeZePostGres == 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Freeze !!! Aborting...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Remote statistics.: {$InfluxUseRemote}\n";
}
if (!$users->POSTFIX_INSTALLED) {
$EnableIntelCeleron = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableIntelCeleron"));
if ($EnableIntelCeleron == 1) {
$EnableInfluxDB = 0;
}
}
if (is_file("/etc/artica-postfix/STATS_APPLIANCE")) {
$EnableInfluxDB = 1;
$SquidPerformance = 0;
$EnableIntelCeleron = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Statistics DB.....: {$EnableInfluxDB}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Intel Celeron mode: {$EnableIntelCeleron}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Performance.......: {$SquidPerformance}\n";
}
if ($EnableInfluxDB == 0) {
build_progress_restart("{starting} {failed} {disabled}", 110);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableInflux)\n";
}
return;
}
//.........这里部分代码省略.........
示例4: start
//.........这里部分代码省略.........
$enabled = 0;
}
}
}
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} EnablePHPFPM............: {$EnablePHPFPM}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} EnablePHPFPMFrameWork...: {$EnablePHPFPMFrameWork}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} EnableArticaApachePHPFPM: {$EnableArticaApachePHPFPM}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} EnablePHPFPMFreeWeb.....: {$EnablePHPFPMFreeWeb}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Enabled.................: {$enabled}\n";
}
if ($enabled == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} is disabled...\n";
}
stop();
}
if (!is_file($phpcgi)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} FATAL no php-cgi can be enabled !\n";
}
return false;
}
$unix->chmod_func(0777, "/var/run");
if ($unix->is_socket("/var/run/php-fcgi.sock")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} remove old socket /var/run/php-fcgi.sock\n";
}
@unlink("/var/run/php-fcgi.sock");
}
$params = LOAD_CMDLINES();
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} version {$params["VERSION"]}\n";
}
$PROCESSES = 3;
$CHILDREN = 5;
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
if ($MEMORY < 624288) {
$PROCESSES = 1;
$CHILDREN = 2;
}
$pid = $unix->get_pid_from_file("/var/run/spawn-fcgi.pid");
$f[] = $spawn_fcgi;
$f[] = "-s /var/run/php-fcgi.sock";
if (isset($params["C"])) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$PROCESSES} Processes\n";
}
$f[] = "-C {$PROCESSES}";
}
if (isset($params["F"])) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$CHILDREN} Children\n";
}
$f[] = "-F {$CHILDREN}";
}
$f[] = "-u www-data -g www-data";
$f[] = "-f {$phpcgi}";
$f[] = "-P /var/run/spawn-fcgi.pid";
$cmd = @implode(" ", $f);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$cmd}\n";
}
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
shell_exec($cmd);
for ($i = 0; $i < 4; $i++) {
$pid = DEFAULT_PID();
if ($unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting {$i}/4...\n";
}
sleep(1);
}
$pid = DEFAULT_PID();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Success service started pid:{$pid}...\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} failed...\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n";
}
}
}
示例5: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$Masterbin = $unix->find_program("arpd");
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, arpd not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} not enough memory\n";
}
if ($unix->process_exists($pid)) {
stop();
}
return;
}
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
return;
}
$EnableSargGenerator = intval($sock->GET_INFO("EnableSargGenerator"));
$EnableSargWeb = intval($sock->GET_INFO("EnableSargWeb"));
if ($EnableSargGenerator == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableSargGenerator)\n";
}
return;
}
if ($EnableSargWeb == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableSargWeb)\n";
}
return;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$nohup = $unix->find_program("nohup");
$apache2ctl = $unix->LOCATE_APACHE_CTL();
apache_config();
$cmd = "{$apache2ctl} -f {$GLOBALS["APACHE_CONFIG_PATH"]} -k start";
shell_exec($cmd);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
}
shell_exec($cmd);
for ($i = 1; $i < 5; $i++) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
}
sleep(1);
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
break;
}
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Failed\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$cmd}\n";
}
}
}
示例6: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$Masterbin = "/usr/bandwidthd/bandwidthd";
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, arpd not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} not enough memory\n";
}
if ($unix->process_exists($pid)) {
stop();
}
return;
}
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
return;
}
$EnableDaemon = intval($sock->Bandwidthd_enabled());
if ($EnableDaemon == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableBandwidthd)\n";
}
return;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$nohup = $unix->find_program("nohup");
build();
$cmd = "{$nohup} {$Masterbin} >/dev/null 2>&1 &";
@unlink("/var/run/bandwidthd.pid");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
}
shell_exec($cmd);
for ($i = 1; $i < 5; $i++) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
}
sleep(1);
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
break;
}
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Failed\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$cmd}\n";
}
}
}
示例7: buildConfig
function buildConfig()
{
$unix = new unix();
$sock = new sockets();
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
@mkdir("/usr/share/artica-postfix/framework", 0755, true);
@mkdir("/usr/share/artica-postfix/ressources/sock", 0755, true);
@mkdir("/usr/share/artica-postfix/ressources/web", 0755, true);
@mkdir("/var/run/artica-framework", 0755, true);
$LighttpdRunAsminimal = $sock->GET_INFO("LighttpdRunAsminimal");
$LighttpdArticaMaxProcs = $sock->GET_INFO("LighttpdArticaMaxProcs");
$LighttpdArticaMaxChildren = $sock->GET_INFO("LighttpdArticaMaxChildren");
$PHP_FCGI_MAX_REQUESTS = $sock->GET_INFO("PHP_FCGI_MAX_REQUESTS");
$EnablePHPFPMFrameWork = $sock->GET_INFO("EnablePHPFPMFrameWork");
if (!is_numeric($EnablePHPFPMFrameWork)) {
$EnablePHPFPMFrameWork = 0;
}
if (!is_numeric($LighttpdRunAsminimal)) {
$LighttpdRunAsminimal = 0;
}
if (!is_numeric($LighttpdArticaMaxProcs)) {
$LighttpdArticaMaxProcs = 0;
}
if (!is_numeric($LighttpdArticaMaxChildren)) {
$LighttpdArticaMaxChildren = 0;
}
if (!is_numeric($PHP_FCGI_MAX_REQUESTS)) {
$PHP_FCGI_MAX_REQUESTS = 200;
}
$PHP_FCGI_CHILDREN = 1;
$max_procs = 5;
if ($LighttpdArticaMaxProcs > 0) {
$max_procs = $LighttpdArticaMaxProcs;
}
if ($LighttpdArticaMaxChildren > 0) {
$PHP_FCGI_CHILDREN = $LighttpdArticaMaxChildren;
}
if (!$unix->ISMemoryHiger1G()) {
$PHP_FCGI_CHILDREN = 2;
$max_procs = 2;
$PHP_FCGI_MAX_REQUESTS = 200;
}
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
if ($MEMORY < 624288) {
$LighttpdRunAsminimal = 1;
}
if ($LighttpdRunAsminimal == 1) {
$max_procs = 2;
$PHP_FCGI_CHILDREN = 1;
$PHP_FCGI_MAX_REQUESTS = 500;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: MAX Procs............: {$max_procs}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Php5 processes.......: {$PHP_FCGI_CHILDREN}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Max cnx/processes....: {$PHP_FCGI_MAX_REQUESTS}\n";
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$EnablePHPFPM = $sock->GET_INFO("EnablePHPFPM");
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnablePHPFPM = 0;
}
$PHP_FPM_Params = PHP_FPM_Params();
if (!isset($ParseParams["allow-to-run-as-root"])) {
$EnablePHPFPMFrameWork = 0;
}
if ($EnablePHPFPMFrameWork == 0) {
$EnablePHPFPM = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: php-fpm..............: {$phpfpm}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: EnablePHPFPMFrameWork: {$EnablePHPFPMFrameWork}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: EnablePHPFPM.........: {$EnablePHPFPM}\n";
}
if ($EnablePHPFPM == 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Using PHP-FPM........: Yes\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Using PHP-FPM........: No\n";
}
}
$phpcgi_path = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: php-cgi path.........: {$phpcgi_path}\n";
}
$f[] = "#artica-postfix saved by artica lighttpd.conf";
$f[] = "";
$f[] = "server.modules = (";
//.........这里部分代码省略.........
示例8: SERVICE_START
//.........这里部分代码省略.........
@unlink('/var/run/mysqld/mysqld.err');
}
if (is_file("/var/run/mysqld/mysqld.pid")) {
$unix->chown_func($mysql_user, $mysql_user, "/var/run/mysqld/mysqld.pid");
}
if ($MysqlRemoveidbLogs == 1) {
shell_exec('/bin/mv /var/lib/mysql/ib_logfile* /tmp/');
$sock->SET_INFO('MysqlRemoveidbLogs', '0');
}
$logpathstring = " --log-error={$MySQLLOgErrorPath}";
if ($EnableMysqlLog == 1) {
$logpathstring = " --log=/var/log/mysql.log --log-slow-queries=/var/log/mysql-slow-queries.log --log-error={$MySQLLOgErrorPath} --log-warnings";
}
$toTouch[] = "/var/log/mysql-slow-queries.log";
$toTouch[] = "/var/log/mysql.error";
$toTouch[] = "/var/log/mysql.log";
$toTouch[] = "/var/log/mysql.warn";
while (list($num, $filename) = each($toTouch)) {
if (!is_file($filename)) {
@file_put_contents($filename, "#\n");
}
$unix->chown_func($mysql_user, $mysql_user, $filename);
}
echo "Starting......: " . date("H:i:s") . " MySQL Checking : {$datadir}/mysql/host.frm\n";
if (!is_file("{$datadir}/mysql/host.frm")) {
if (is_file($mysql_install_db)) {
echo "Starting......: " . date("H:i:s") . " MySQL Installing default databases\n";
shell_exec("{$mysql_install_db} --datadir=\"{$datadir}\"");
}
} else {
echo "Starting......: " . date("H:i:s") . " MySQL Checking : {$datadir}/mysql/host.frm OK\n";
}
$cmd2 = array();
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
$AsCategoriesAppliance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/AsCategoriesAppliance"));
if ($AsCategoriesAppliance == 1) {
$MEMORY = 620288;
}
if ($MEMORY < 624288) {
$GetStartedValues = GetStartedValues();
echo "Starting......: " . date("H:i:s") . " MySQL Warning memory did not respond to pre-requesites, tuning to lower memory\n";
if ($GetStartedValues["--key-buffer-size"]) {
$cmd2[] = "--key-buffer-size=8M";
}
if ($GetStartedValues["--max-allowed-packet"]) {
$cmd2[] = "--max-allowed-packet=4M";
}
if ($GetStartedValues["--table-cache"]) {
$cmd2[] = "--table-cache=4";
}
if ($GetStartedValues["--sort-buffer-size"]) {
$cmd2[] = "--sort-buffer-size=64k";
}
if ($GetStartedValues["--read-buffer-size"]) {
$cmd2[] = "--read-buffer-size=256k";
}
if ($GetStartedValues["--read-rnd-buffer-size"]) {
$cmd2[] = "--read-rnd-buffer-size=128k";
}
if ($GetStartedValues["--net-buffer-length"]) {
$cmd2[] = "--net-buffer-length=2k";
}
if ($GetStartedValues["--thread-stack"]) {
$cmd2[] = "--thread-stack=192k";
}
if ($GetStartedValues["--thread-cache-size"]) {
示例9: WizardExecute
//.........这里部分代码省略.........
@chmod("/usr/share/artica-postfix/bin/process1", 0755);
writeprogress(17, "{building_openldap_configuration_file}");
system("/usr/share/artica-postfix/bin/artica-install --slapdconf >>{$DEBUG_LOG} 2>&1");
writeprogress(18, "{restarting_service} {openldap_server} [{$suffix}] (1/3)");
shell_exec("{$php5} /usr/share/artica-postfix/exec.initslapd.php --ldapd-conf --verbose >>{$DEBUG_LOG} 2>&1");
system("/etc/init.d/slapd restart --force --framework=" . basename(__FILE__) . "-" . __LINE__ . " >>{$DEBUG_LOG} 2>&1");
usleep(800);
writeprogress(19, "{restarting_service} {openldap_server} [{$suffix}] (2/3)");
system("/etc/init.d/slapd restart --force --framework=" . basename(__FILE__) . "-" . __LINE__ . " >>{$DEBUG_LOG} 2>&1");
usleep(800);
writeprogress(20, "{restarting_service} {openldap_server} [{$suffix}] (3/3)");
system("/etc/init.d/slapd restart --force --framework=" . basename(__FILE__) . "-" . __LINE__ . " >>{$DEBUG_LOG} 2>&1");
sleep(2);
writeprogress(22, "{refresh_global_settings}");
system('/usr/share/artica-postfix/bin/process1 --checkout --force --verbose ' . time());
writeprogress(23, "{scanning_hardware_software}");
system('/usr/share/artica-postfix/bin/process1 --force --verbose ' . time());
$SUBNIC = null;
FINAL___();
@file_get_contents($pidfile, getmypid());
writeprogress(24, "{restarting_service}: {mysql_server}");
system('/etc/init.d/mysql restart --force');
sleep(1);
$users = new usersMenus();
$q = new mysql();
writeprogress(25, "{creating_databases}");
sleep(1);
$q->BuildTables();
$sock = new sockets();
$CPU_NUMBERS = $unix->CPU_NUMBER();
if ($CPU_NUMBERS == 0) {
$CPU_NUMBERS = 4;
}
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
$MEMORY_TEXT = FormatBytes($MEMORY);
$INTEL_CELERON = FALSE;
writeprogress(25, "CPUs {$CPU_NUMBERS} - {memory}: {$MEMORY_TEXT}");
sleep(2);
if ($MEMORY > 1) {
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
@file_put_contents("/etc/artica-postfix/settings/Daemons/EnableIntelCeleron", 1);
@file_put_contents("/etc/artica-postfix/settings/Daemons/SquidPerformance", 3);
writeprogress(25, "{$MEMORY_TEXT} = Enable Intel Celeron mode....");
shell_exec("{$php5} /usr/share/artica-postfix/exec.intel.celeron.php");
$INTEL_CELERON = true;
}
}
if (!$INTEL_CELERON) {
if ($CPU_NUMBERS < 2) {
@file_put_contents("/etc/artica-postfix/settings/Daemons/EnableIntelCeleron", 1);
@file_put_contents("/etc/artica-postfix/settings/Daemons/SquidPerformance", 3);
writeprogress(25, "CPUs:{$CPU_NUMBERS} = Intel Celeron mode....");
shell_exec("{$php5} /usr/share/artica-postfix/exec.intel.celeron.php");
$INTEL_CELERON = true;
}
}
if (!$INTEL_CELERON) {
if ($CPU_NUMBERS < 3) {
@file_put_contents("/etc/artica-postfix/settings/Daemons/SquidPerformance", 2);
writeprogress(25, "CPUs:{$CPU_NUMBERS} = {features}: {no_statistics}");
sleep(1);
}
}
writeprogress(26, "{creating_services}");
shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.initslapd.php --force >/dev/null 2>&1 &");
if (is_file($squidbin)) {
示例10: start_ldap
//.........这里部分代码省略.........
$suffix = @trim(@file_get_contents("/etc/artica-postfix/ldap_settings/suffix"));
shell_exec("{$nohup} /usr/share/artica-postfix/exec.virtuals-ip.php --resolvconf >/dev/null 2>&1 &");
echo "slapd: [INFO] slapd `{$slapd}`\n";
echo "slapd: [INFO] db_recover `{$DB_RECOVER_BIN}`\n";
echo "slapd: [INFO] db_archive `{$DB_ARCHIVE_BIN}`\n";
echo "slapd: [INFO] config `{$SLAPD_CONF}`\n";
echo "slapd: [INFO] pid `{$SLAPD_PID_FILE}`\n";
echo "slapd: [INFO] services `{$SLAPD_SERVICES}`\n";
echo "slapd: [INFO] pidof `{$pidofbin}`\n";
if ($EnableipV6 == 0) {
echo "slapd: [INFO] ipv4 only...\n";
$v4 = " -4";
}
if ($GLOBALS["VERBOSE"]) {
echo "-> ARRAY;\n";
}
$shemas[] = "core.schema";
$shemas[] = "cosine.schema";
$shemas[] = "mod_vhost_ldap.schema";
$shemas[] = "nis.schema";
$shemas[] = "inetorgperson.schema";
$shemas[] = "evolutionperson.schema";
$shemas[] = "postfix.schema";
$shemas[] = "dhcp.schema";
$shemas[] = "samba.schema";
$shemas[] = "ISPEnv.schema";
$shemas[] = "mozilla-thunderbird.schema";
$shemas[] = "officeperson.schema";
$shemas[] = "pureftpd.schema";
$shemas[] = "joomla.schema";
$shemas[] = "autofs.schema";
$shemas[] = "dnsdomain2.schema";
$shemas[] = "zarafa.schema";
restart_ldap_progress("{starting_service}", 50);
while (list($num, $file) = each($shemas)) {
if (is_file("/usr/share/artica-postfix/bin/install/{$file}")) {
if (is_file("{$LDAP_SCHEMA_PATH}/{$file}")) {
@unlink("{$LDAP_SCHEMA_PATH}/{$file}");
}
@copy("/usr/share/artica-postfix/bin/install/{$file}", "{$LDAP_SCHEMA_PATH}/{$file}");
echo "slapd: [INFO] installing `{$file}` schema\n";
$unix->chmod_func(0777, "{$LDAP_SCHEMA_PATH}/{$file}");
}
}
if (file_exists($ulimit)) {
shell_exec("{$ulimit} -HSd unlimited");
}
restart_ldap_progress("{starting_service}", 60);
if (is_dir("/usr/share/phpldapadmin/config")) {
$phpldapadmin = "{$php5} " . dirname(__FILE__) . "/exec.phpldapadmin.php --build >/dev/null 2>&1";
echo "slapd: [INFO] please wait, configuring PHPLdapAdminservice... \n";
shell_exec($phpldapadmin);
}
echo "slapd: [INFO] please wait, configuring the daemon...\n";
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
$sock = new sockets();
$sock->SET_INFO("SlapdThreads", 2);
}
restart_ldap_progress("{starting_service}", 70);
@chmod("/usr/share/artica-postfix/bin/artica-install", 0755);
shell_exec("/usr/share/artica-postfix/bin/artica-install --slapdconf");
echo "slapd: [INFO] please wait, building the start script...\n";
buildscript();
$unix->ToSyslog("Launching the OpenLDAP daemon ", false, basename(__FILE__));
echo "slapd: [INFO] please wait, Launching the daemon...\n";
if (!$unix->NETWORK_INTERFACE_OK("lo")) {
$ifconfig = $unix->find_program("ifconfig");
shell_exec("{$ifconfig} lo 127.0.0.1 netmask 255.255.255.0 up >/dev/null 2>&1");
}
restart_ldap_progress("{starting_service}", 80);
$cdmline = "{$nohup} {$slapd}{$v4} -h \"{$SLAPD_SERVICES}\" -f {$SLAPD_CONF} -u root -g root -l local4{$OpenLDAPLogLevelCmdline} >/dev/null 2>&1 &";
shell_exec($cdmline);
sleep(1);
for ($i = 0; $i < 5; $i++) {
$pid = $unix->get_pid_from_file($SLAPD_PID_FILE);
if ($unix->process_exists($pid)) {
$pidtime = $unix->PROCCESS_TIME_MIN($pid);
echo "slapd: [INFO] slapd success Running pid {$pid}\n";
restart_ldap_progress("{success}", 100);
if ($users->ZARAFA_INSTALLED) {
start_zarafa();
}
return;
}
$pid = $unix->PIDOF($slapd);
if ($unix->process_exists($pid)) {
$pidtime = $unix->PROCCESS_TIME_MIN($pid);
echo "slapd: [INFO] slapd success Running pid {$pid}\n";
if ($users->ZARAFA_INSTALLED) {
start_zarafa();
}
restart_ldap_progress("{success}", 100);
return;
}
echo "slapd: [INFO] please wait, waiting service to start...\n";
sleep(1);
}
restart_ldap_progress("{failed}", 110);
echo "slapd: [ERR ] Failed to start the service with `{$cdmline}`\n";
}
示例11: MEM_TOTAL_INSTALLEE
function MEM_TOTAL_INSTALLEE()
{
$unix = new unix();
$MEM_TOTAL_INSTALLEE = $unix->MEM_TOTAL_INSTALLEE();
echo "<articadatascgi>{$MEM_TOTAL_INSTALLEE}</articadatascgi>";
}
示例12: build
//.........这里部分代码省略.........
$f = array();
@unlink("/etc/monit/conf.d/APP_OPENSSH.monitrc");
@unlink("/etc/monit/conf.d/APP_MYSQLD.monitrc");
//********************************************************************************************************************
$f = array();
$f[] = "check process APP_ARTICA_STATUS with pidfile /etc/artica-postfix/exec.status.php.pid";
$f[] = "\tstart program = \"/etc/init.d/artica-status start --monit\"";
$f[] = "\tstop program = \"/etc/init.d/artica-status stop --monit\"";
$f[] = "\tif 5 restarts within 5 cycles then timeout";
$f[] = "";
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Artica Status...\n";
}
@file_put_contents("/etc/monit/conf.d/APP_ARTICASTATUS.monitrc", @implode("\n", $f));
//********************************************************************************************************************
$f = array();
@unlink("/etc/monit/conf.d/squid.monitrc");
@unlink("/etc/monit/conf.d/APP_SQUIDMAIN.monitrc");
if (is_file($squidbin)) {
if ($SQUIDEnable == 1) {
$MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
$SquidMgrListenPort = trim($sock->GET_INFO("SquidMgrListenPort"));
if (!is_numeric($MonitConfig["watchdog"])) {
$MonitConfig["watchdog"] = 1;
}
if (!is_numeric($MonitConfig["watchdogCPU"])) {
$MonitConfig["watchdogCPU"] = 95;
}
if (!is_numeric($MonitConfig["watchdogMEM"])) {
$MonitConfig["watchdogMEM"] = 1500;
}
if ($MonitConfig["watchdog"] == 1) {
if ($MonitConfig["watchdogMEM"] > 500) {
$AVAILABLE_MEM = $unix->MEM_TOTAL_INSTALLEE();
$AVAILABLE_MEM = $AVAILABLE_MEM / 1024;
$prc = $MonitConfig["watchdogMEM"] / $AVAILABLE_MEM;
$prc = round($prc * 100);
}
$f = array();
$f[] = "check process APP_SQUID with pidfile /var/run/squid/squid.pid";
$f[] = "\tstart program = \"/etc/init.d/squid start --monit\"";
$f[] = "\tstop program = \"/etc/init.d/squid stop --monit\"";
if ($SquidMgrListenPort > 0) {
$f[] = "\tif failed host 127.0.0.1 port {$SquidMgrListenPort} then restart";
}
if ($MonitConfig["watchdogCPU"] > 60) {
$f[] = "\tif cpu usage > {$MonitConfig["watchdogCPU"]}% for 5 cycles then restart";
}
if ($prc > 10) {
$f[] = "\tif mem usage > {$prc}% for 5 cycles then restart";
}
$f[] = "\tif 5 restarts within 5 cycles then timeout";
$f[] = "";
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} monitoring Squid-Cache...\n";
}
@file_put_contents("/etc/monit/conf.d/APP_SQUIDMAIN.monitrc", @implode("\n", $f));
}
}
}
// ********************************************************************************************************************
$f = array();
@unlink("/etc/monit/conf.d/APP_SQUIDDB.monitrc");
if (is_dir("/opt/squidsql/data")) {
if ($SQUIDEnable == 1) {
$f = array();
示例13: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$Masterbin = $unix->find_program("arpd");
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, arpd not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} not enough memory\n";
}
if ($unix->process_exists($pid)) {
stop();
}
return;
}
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
return;
}
$EnableArpDaemon = $sock->GET_INFO("EnableArpDaemon");
$ArpdKernelLevel = $sock->GET_INFO("ArpdKernelLevel");
if (!is_numeric($EnableArpDaemon)) {
$EnableArpDaemon = 1;
}
if (!is_numeric($ArpdKernelLevel)) {
$ArpdKernelLevel = 0;
}
if ($EnableArpDaemon == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableArpDaemon)\n";
}
return;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$nohup = $unix->find_program("nohup");
if ($ArpdKernelLevel > 0) {
$ArpdKernelLevel_string = " -a {$ArpdKernelLevel}";
}
$Interfaces = $unix->NETWORK_ALL_INTERFACES();
$nic = new system_nic();
while (list($Interface, $ligne) = each($Interfaces)) {
if ($Interface == "lo") {
continue;
}
if ($ligne["IPADDR"] == "0.0.0.0") {
continue;
}
$Interface = $nic->NicToOther($Interface);
$TRA[$Interface] = $Interface;
}
while (list($Interface, $ligne) = each($TRA)) {
$TR[] = $Interface;
}
@mkdir('/var/lib/arpd', 0755, true);
$f[] = "{$Masterbin} -b /var/lib/arpd/arpd.db";
$f[] = $ArpdKernelLevel;
if (count($TR) > 0) {
$f[] = "-k " . @implode($TR, " ");
}
$cmd = @implode(" ", $f) . " >/dev/null 2>&1 &";
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
}
shell_exec($cmd);
for ($i = 1; $i < 5; $i++) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
}
sleep(1);
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
break;
}
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
//.........这里部分代码省略.........
示例14: build
function build()
{
$unix = new unix();
$sock = new sockets();
$Isagetway = false;
$INSTALL_SERVICE = false;
$KernelSendRedirects = $sock->GET_INFO("KernelSendRedirects");
if (!is_numeric($KernelSendRedirects)) {
$KernelSendRedirects = 1;
}
$conntrack = $unix->find_program("conntrack");
$EnableChilli = $sock->GET_INFO("EnableChilli");
$EnableArticaAsGateway = $sock->GET_INFO("EnableArticaAsGateway");
if (!is_numeric($EnableChilli)) {
$EnableChilli = 0;
}
$hasProxyTransparent = $sock->GET_INFO("hasProxyTransparent");
if (!is_numeric($hasProxyTransparent)) {
$hasProxyTransparent = 0;
}
$hostname = trim(@file_get_contents("/etc/artica-postfix/FULL_HOSTNAME"));
if ($EnableChilli == 1) {
$Isagetway = true;
}
if ($EnableArticaAsGateway == 1) {
$Isagetway = true;
}
if ($hasProxyTransparent == 1) {
$Isagetway = true;
}
if (is_file("/etc/artica-postfix/IPTABLES_BR_BRIDGE")) {
$Isagetway = true;
}
if (is_file("/etc/artica-postfix/IPTABLES_BRIDGE")) {
$Isagetway = true;
}
$EnableipV6 = $sock->GET_INFO("EnableipV6");
if (!is_numeric($EnableipV6)) {
$EnableipV6 = 0;
}
$ARRAY = unserialize(base64_decode($sock->GET_INFO("kernel_values")));
$swappiness = intval($ARRAY["swappiness"]);
if ($swappiness == 0) {
$swappiness = 10;
}
$tcp_max_syn_backlog = $ARRAY["tcp_max_syn_backlog"];
if (!is_numeric($tcp_max_syn_backlog)) {
$tcp_max_syn_backlog = 1024;
}
$EnableTCPOptimize = $sock->GET_INFO("EnableTCPOptimize");
$DisableConntrack = intval($sock->GET_INFO("DisableConntrack"));
if (!is_numeric($EnableTCPOptimize)) {
$EnableTCPOptimize = 1;
}
$DisableTCPOptimizations = $sock->GET_INFO("DisableTCPOptimizations");
if ($DisableTCPOptimizations == 1) {
$EnableTCPOptimize = 0;
}
$echo = $unix->find_program("echo");
$modprobe = $unix->find_program("modprobe");
$DisableTCPEn = intval(trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/DisableTCPEn")));
$DisableTCPWindowScaling = intval(trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/DisableTCPWindowScaling")));
$EnableSystemOptimize = intval(trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSystemOptimize")));
$tcp_ecn = 2;
$tcp_window_scaling = 1;
if ($DisableTCPWindowScaling == 1) {
$tcp_window_scaling = 0;
}
if ($DisableTCPEn == 1) {
$tcp_ecn = 0;
}
$sysctl = $unix->find_program("sysctl");
$f[] = "#";
$f[] = "# /etc/sysctl.conf - Configuration file for setting system variables";
$f[] = "# See /etc/sysctl.d/ for additonal system variables";
$f[] = "# See sysctl.conf (5) for information.";
$f[] = "#";
$f[] = "";
$f[] = "#kernel.domainname = example.com";
$f[] = "";
$f[] = "# Uncomment the following to stop low-level messages on console";
$f[] = "#kernel.printk = 3 4 1 3";
$f[] = "";
$f[] = "##############################################################";
// /proc/sys/vm/dirty_ratio defaults to 20% of RAM
// /proc/sys/vm/dirty_background_ratio defaults to 10%of RAM
$memory = $unix->MEM_TOTAL_INSTALLEE() * 1024;
$dirty_ratio = round($memory * 0.8);
if ($EnableSystemOptimize == 0) {
shell_exec("{$echo} 33554432 >/proc/sys/vm/dirty_background_bytes");
shell_exec("{$echo} {$dirty_ratio} >/proc/sys/vm/dirty_bytes");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Memory: {$memory} bytes\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} dirty_ratio = {$dirty_ratio} bytes \n";
}
} else {
$swappiness = 0;
shell_exec("{$echo} 1024 > /sys/block/sda/queue/nr_requests");
//.........这里部分代码省略.........
示例15: buildConfig
function buildConfig()
{
$unix = new unix();
$sock = new sockets();
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
$chown = $unix->find_program("chown");
$perlbin = $unix->find_program("perl");
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
$PHP_STANDARD_MODE = true;
$phpfpm = $unix->find_program('php5-fpm');
if (!is_file($phpfpm)) {
$phpfpm = $unix->find_program('php-fpm');
}
@mkdir("/usr/share/artica-postfix/framework", 0755, true);
@mkdir("/usr/share/artica-postfix/ressources/sock", 0755, true);
$LighttpdRunAsminimal = $sock->GET_INFO("LighttpdRunAsminimal");
$LighttpdArticaMaxProcs = $sock->GET_INFO("LighttpdArticaMaxProcs");
$LighttpdArticaMaxChildren = $sock->GET_INFO("LighttpdArticaMaxChildren");
$PHP_FCGI_MAX_REQUESTS = $sock->GET_INFO("PHP_FCGI_MAX_REQUESTS");
$SessionPathInMemory = $sock->GET_INFO("SessionPathInMemory");
if (!is_numeric($LighttpdRunAsminimal)) {
$LighttpdRunAsminimal = 0;
}
if (!is_numeric($LighttpdArticaMaxProcs)) {
$LighttpdArticaMaxProcs = 0;
}
if (!is_numeric($LighttpdArticaMaxChildren)) {
$LighttpdArticaMaxChildren = 0;
}
if (!is_numeric($PHP_FCGI_MAX_REQUESTS)) {
$PHP_FCGI_MAX_REQUESTS = 200;
}
if (!is_numeric($SessionPathInMemory)) {
$SessionPathInMemory = 0;
}
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file("/opt/artica/ssl/certs/lighttpd.pem")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} creating SSL certificate..\n";
}
exec("/usr/share/artica-postfix/bin/artica-install -lighttpd-cert 2>&1", $results);
while (list($pid, $line) = each($results)) {
$line = trim($line);
if ($line == null) {
continue;
}
if (preg_match("#Starting.*?lighttpd(.+)#", $line, $re)) {
$line = $re[1];
}
$line = str_replace(": ", "", $line);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [ARTI]: {$GLOBALS["SERVICE_NAME"]} {$line}\n";
}
}
}
$results = array();
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Creating PHP configuration..\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Executing artica-install --php-ini..\n";
}
exec("/usr/share/artica-postfix/bin/artica-install --php-ini 2>&1", $results);
while (list($pid, $line) = each($results)) {
$line = trim($line);
if ($line == null) {
continue;
}
if (preg_match("#Starting.*?lighttpd(.+)#", $line, $re)) {
$line = $re[1];
}
$line = str_replace(": ", "", $line);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [ARTI]: {$GLOBALS["SERVICE_NAME"]} {$line}\n";
}
}
PHP_MYADMIN();
$PHP_FCGI_CHILDREN = 3;
$max_procs = 3;
if ($LighttpdArticaMaxProcs > 0) {
$max_procs = $LighttpdArticaMaxProcs;
}
if ($LighttpdArticaMaxChildren > 0) {
$PHP_FCGI_CHILDREN = $LighttpdArticaMaxChildren;
}
if (!$unix->ISMemoryHiger1G()) {
$PHP_FCGI_CHILDREN = 2;
$max_procs = 1;
}
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
if ($MEMORY < 624288) {
$LighttpdRunAsminimal = 1;
}
if ($LighttpdRunAsminimal == 1) {
$max_procs = 1;
$PHP_FCGI_CHILDREN = 2;
//.........这里部分代码省略.........