本文整理汇总了PHP中apache_child_terminate函数的典型用法代码示例。如果您正苦于以下问题:PHP apache_child_terminate函数的具体用法?PHP apache_child_terminate怎么用?PHP apache_child_terminate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apache_child_terminate函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moodle_request_shutdown
/**
* This function expects to called during shutdown
* should be set via register_shutdown_function()
* in lib/setup.php .
*
* @return void
*/
function moodle_request_shutdown()
{
global $CFG;
// help apache server if possible
$apachereleasemem = false;
if (function_exists('apache_child_terminate') && function_exists('memory_get_usage') && ini_get_bool('child_terminate')) {
$limit = empty($CFG->apachemaxmem) ? 64 * 1024 * 1024 : $CFG->apachemaxmem;
//64MB default
if (memory_get_usage() > get_real_size($limit)) {
$apachereleasemem = $limit;
@apache_child_terminate();
}
}
// deal with perf logging
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if ($apachereleasemem) {
error_log('Mem usage over ' . $apachereleasemem . ': marking Apache child for reaping.');
}
if (defined('MDL_PERFTOLOG')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFINC')) {
$inc = get_included_files();
$ts = 0;
foreach ($inc as $f) {
if (preg_match(':^/:', $f)) {
$fs = filesize($f);
$ts += $fs;
$hfs = display_size($fs);
error_log(substr($f, strlen($CFG->dirroot)) . " size: {$fs} ({$hfs})", NULL, NULL, 0);
} else {
error_log($f, NULL, NULL, 0);
}
}
if ($ts > 0) {
$hts = display_size($ts);
error_log("Total size of files included: {$ts} ({$hts})");
}
}
}
}
示例2: moodle_request_shutdown
function moodle_request_shutdown()
{
global $CFG;
// initially, we are only ever called under apache
// but check just in case
if (function_exists('apache_child_terminate') && function_exists('memory_get_usage') && ini_get_bool('child_terminate')) {
if (empty($CFG->apachemaxmem)) {
$CFG->apachemaxmem = 25000000;
// default 25MiB
}
if (memory_get_usage() > (int) $CFG->apachemaxmem) {
trigger_error('Mem usage over $CFG->apachemaxmem: marking child for reaping.');
@apache_child_terminate();
}
}
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if (defined('MDL_PERFTOLOG')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
if (defined('MDL_PERFINC')) {
$inc = get_included_files();
$ts = 0;
foreach ($inc as $f) {
if (preg_match(':^/:', $f)) {
$fs = filesize($f);
$ts += $fs;
$hfs = display_size($fs);
error_log(substr($f, strlen($CFG->dirroot)) . " size: {$fs} ({$hfs})", NULL, NULL, 0);
} else {
error_log($f, NULL, NULL, 0);
}
}
if ($ts > 0) {
$hts = display_size($ts);
error_log("Total size of files included: {$ts} ({$hts})");
}
}
}
}
示例3: terminate
/**
* 在本次请求结束后终止 apache 子进程
* <code>Apache::terminate();</code>
* @return bool 成功返回true,失败返回false
*/
public static function terminate()
{
return @apache_child_terminate();
}
示例4: message
//.........这里部分代码省略.........
//if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == False)
//{
// fix a b0rk in template showing last item 2 times under XSLT
$final_V_display_part = '';
//}
$count_part_nice = count($this->bo->part_nice);
for ($i = 0; $i < $count_part_nice; $i++) {
if ($this->bo->part_nice[$i]['d_instructions'] == 'show') {
$this->tpl->set_var('title_text', $this->bo->part_nice[$i]['title_text']);
$this->tpl->set_var('display_str', $this->bo->part_nice[$i]['display_str']);
$this->tpl->set_var('message_body', $this->bo->part_nice[$i]['message_body']);
//$this->tpl->parse('V_display_part','B_display_part', True);
//if ($GLOBALS['phpgw']->msg->phpgw_before_xslt)
//{
// $this->tpl->parse('V_display_part','B_display_part', True);
//}
//else
//{
// fix a b0rk in template showing last item 2 times under XSLT
$final_V_display_part .= $this->tpl->parse('V_display_part', 'B_display_part');
//}
} elseif ($this->bo->part_nice[$i]['d_instructions'] == 'echo_out') {
// output a blank message body, we'll use an alternate method below
$this->tpl->set_var('V_display_part', '');
// ----- Finished With Message_Mail Template, Output It
$this->tpl->pfp('out', 'T_message_main');
// ----- Prepare a Table for this Echo Dump
$this->tpl->set_var('title_text', $this->bo->part_nice[$i]['title_text']);
$this->tpl->set_var('display_str', $this->bo->part_nice[$i]['display_str']);
$this->tpl->parse('V_setup_echo_dump', 'B_setup_echo_dump');
$this->tpl->set_var('V_done_echo_dump', '');
$this->tpl->pfp('out', 'T_message_echo_dump');
// ----- Prepare $msgball data for phpgw_fetchbody()
$msgball = $GLOBALS['phpgw']->msg->get_arg_value('msgball');
$msgball['part_no'] = $this->bo->part_nice[$i]['m_part_num_mime'];
// ----- Echo This Data Directly to the Client
// since the php version of this of b0rked for large msgs, perhaps use sockets code?
echo '<pre>';
echo $GLOBALS['phpgw']->msg->phpgw_fetchbody($msgball);
echo '</pre>';
// ----- Close Table
$this->tpl->set_var('V_setup_echo_dump', '');
$this->tpl->parse('V_done_echo_dump', 'B_done_echo_dump');
$this->tpl->pfp('out', 'T_message_echo_dump');
// = = = = = ======= CLEANUP AND EXIT PAGE ======= = = = = = =
$did_echo_dump = True;
break;
}
}
//@set_time_limit(0);
//if ($GLOBALS['phpgw']->msg->phpgw_before_xslt == False)
//{
// // fix a b0rk in template showing last item 2 times under XSLT
$this->tpl->set_var('V_display_part', $final_V_display_part);
$final_V_display_part = '';
unset($final_V_display_part);
//}
// new way to handle debug data, if there is debug data, this will put it in the template source data vars
$this->tpl->set_var('debugdata', $GLOBALS['phpgw']->msg->dbug->notice_pagedone());
if (isset($did_echo_dump) && $did_echo_dump == True) {
// DO NOTHING!
// echo dump already outputted the template
} elseif ($GLOBALS['phpgw']->msg->phpgw_before_xslt) {
$this->tpl->pfp('out', 'T_message_main');
//$GLOBALS['phpgw']->common->phpgw_footer();
} else {
$this->tpl->set_unknowns('comment');
//$this->tpl->set_unknowns('remove');
$data = array();
//$data['appname'] = lang('E-Mail');
//$data['function_msg'] = lang('show message');
$GLOBALS['phpgw_info']['flags']['email']['app_header'] = lang('E-Mail') . ': ' . lang('show message');
$data['email_page'] = $this->tpl->parse('out', 'T_message_main');
// new way to handle debug data, if this array has anything, put it in the template source data vars
//if ($GLOBALS['phpgw']->msg->dbug->debugdata)
//{
// $data['debugdata'] = $GLOBALS['phpgw']->msg->dbug->get_debugdata_stack();
//}
//$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uimessage' => $data));
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('generic_out' => $data));
}
// ralfbecker patch dated 021124
if (isset($this->bo->xi['application'])) {
global $calendar_id;
$calendar_id = $this->bo->xi['calendar_id'];
$GLOBALS['phpgw']->hooks->single('email', $this->bo->xi['application']);
}
// tell apache to release emeory back to the system on script end
//if ((isset($_SERVER['SERVER_SOFTWARE']))
//&& (stristr($_SERVER['SERVER_SOFTWARE'], 'apache'))
if (getenv('SERVER_SOFTWARE') && stristr(getenv('SERVER_SOFTWARE'), 'apache') && function_exists('apache_child_terminate') && ini_get('child_terminate')) {
//echo 'doing apache_child_terminate';
apache_child_terminate();
}
// close down ALL mailserver streams
$GLOBALS['phpgw']->msg->end_request();
// destroy the object
$GLOBALS['phpgw']->msg = '';
unset($GLOBALS['phpgw']->msg);
}
示例5: vmoodle_parse_csv_snaplist
/**
* Opens and parses/checks a VMoodle nodelist for snapshotting. Basically
* compatible with nodelist format.
* @param string $nodelistlocation
*/
function vmoodle_parse_csv_snaplist($nodelistlocation = '')
{
global $CFG;
vmoodle_setup_local_config();
$vnodes = array();
if (empty($nodelistlocation)) {
$nodelistlocation = $CFG->dataroot . '/vmoodle/snaplist.csv';
}
// Decode file.
$csv_encode = '/\\&\\#44/';
if (isset($CFG->local_vmoodle_csvseparator)) {
$csv_delimiter = '\\' . $CFG->local_vmoodle_csvseparator;
$csv_delimiter2 = $CFG->local_vmoodle_csvseparator;
if (isset($CFG->CSV_ENCODE)) {
$csv_encode = '/\\&\\#' . $CFG->CSV_ENCODE . '/';
}
} else {
$csv_delimiter = "\\;";
$csv_delimiter2 = ";";
}
/*
* File that is used is currently hardcoded here !
* Large files are likely to take their time and memory. Let PHP know
* that we'll take longer, and that the process should be recycled soon
* to free up memory.
*/
@set_time_limit(0);
@raise_memory_limit("1024M");
if (function_exists('apache_child_terminate')) {
@apache_child_terminate();
}
// Make arrays of valid fields for error checking.
$required = array('vhostname' => 1);
// this will allow using a node creation list to operate
$optional = array('name' => 1, 'shortname' => 1, 'vdatapath' => 1, 'vdbname' => 1, 'vdblogin' => 1, 'vdbpass' => 1, 'description' => 1, 'vdbhost' => 1, 'vdbpersist' => 1, 'vtemplate' => 1, 'services' => 1, 'enabled' => 1, 'mnet' => 1);
$optionalDefaults = array('mnet' => 1, 'vdbtype' => 'mysqli', 'vdbhost' => $CFG->dbhost, 'vdbpersist' => $CFG->dboptions['dbpersist'], 'vdbprefix' => 'mdl_', 'vtemplate' => '', 'enabled' => 1, 'services' => 'default');
$patterns = array();
$metas = array('auth_.*', 'block_.*', 'mod_.*', 'local_.*', 'report_.*', 'format_.*', 'config_.*');
// Get header (field names).
$textlib = new textlib();
if (!($fp = fopen($nodelistlocation, 'rb'))) {
cli_error(get_string('badnodefile', 'local_vmoodle', $nodelistlocation));
}
// Jump any empty or comment line.
$text = fgets($fp, 1024);
$i = 0;
while (vmoodle_is_empty_line_or_format($text, $i == 0)) {
$text = fgets($fp, 1024);
$i++;
}
$headers = explode($csv_delimiter2, $text);
// Check for valid field names.
foreach ($headers as $h) {
$header[] = trim($h);
$patternized = implode('|', $patterns) . "\\d+";
$metapattern = implode('|', $metas);
if (!(isset($required[$h]) or isset($optionalDefaults[$h]) or isset($optional[$h]) or preg_match("/{$patternized}/", $h) or preg_match("/{$metapattern}/", $h))) {
cli_error(get_string('invalidfieldname', 'error', $h));
return;
}
if (isset($required[trim($h)])) {
$required[trim($h)] = 0;
}
}
// Check for required fields.
foreach ($required as $key => $value) {
if ($value) {
// Required field missing.
cli_error(get_string('fieldrequired', 'error', $key));
return;
}
}
$linenum = 2;
// Since header is line 1.
// Take some from admin profile, other fixed by hardcoded defaults.
while (!feof($fp)) {
// Make a new base record.
$vnode = new StdClass();
foreach ($optionalDefaults as $key => $value) {
$vnode->{$key} = $value;
}
// Commas within a field should be encoded as , (for comma separated csv files).
// Semicolon within a field should be encoded as ; (for semicolon separated csv files).
$text = fgets($fp, 1024);
if (vmoodle_is_empty_line_or_format($text, false)) {
$i++;
continue;
}
$valueset = explode($csv_delimiter2, $text);
$f = 0;
foreach ($valueset as $value) {
// Decode encoded commas.
$key = $headers[$f];
$vnode->{$key} = preg_replace($csv_encode, $csv_delimiter2, trim($value));
$f++;
//.........这里部分代码省略.........
示例6: moodle_request_shutdown
function moodle_request_shutdown()
{
global $CFG;
// initially, we are only ever called under apache
// but check just in case
if (function_exists('apache_child_terminate') && function_exists('memory_get_usage') && ini_get_bool('child_terminate')) {
if (empty($CFG->apachemaxmem)) {
$CFG->apachemaxmem = 25000000;
// default 25MiB
}
if (memory_get_usage() > (int) $CFG->apachemaxmem) {
trigger_error('Mem usage over $CFG->apachemaxmem: marking child for reaping.');
@apache_child_terminate();
}
}
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
if (defined('MDL_PERFTOLOG')) {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
}
}
示例7: process_input_data
/**
* Actually process the uploaded CSV organization file upon successful upload.
*
* NOTE: A lot o code here is borrowed / modified from Moodle.
*
* @see Moodle:/admin/uploaduser.php
*
* @uses $CURMAN
* @param array $fieldata A PHP upload file array (i.e. from the $_FILES superglobal).
* @param bool $update Flag for updating existing records.
* @param bool $verbose Flag for verbose output.
* @return string Output for display.
*/
function process_input_data($filedata, $update = false, $verbose = false)
{
global $CURMAN;
$output = '';
/// Don't check for a valid mime/type as this is causing errors for the client.
/*
if (!in_array($filedata['type'], $this->valid_mimetypes)) {
return 'The file format uploaded was incorrect';
}
*/
if ($filedata['size'] === 0) {
return get_string('uploaded_empty_file', 'block_curr_admin');
}
/**
* Large files are likely to take their time and memory. Let PHP know
* that we'll take longer, and that the process should be recycled soon
* to free up memory.
*/
@set_time_limit(0);
@cm_raise_memory_limit('192M');
if (function_exists('apache_child_terminate')) {
@apache_child_terminate();
}
$csv_encode = '/\\&\\#44/';
$csv_delimiter = "\\,";
$csv_delimiter2 = ",";
$data = '';
$file = @fopen($filedata['tmp_name'], 'rb');
if ($file) {
while (!feof($file)) {
$data .= fread($file, 1024);
}
fclose($file);
}
if (empty($data)) {
return get_string('no_data_file', 'block_curr_admin');
}
/**
* Removes the BOM from unicode string - see http://unicode.org/faq/utf_bom.html
*
* Borrowed from Moodle code - /lib/textlib.class.php
*/
$bom = "";
if (strpos($data, $bom) === 0) {
$data = substr($data, strlen($bom));
}
/**
* Fix Mac/DOS newlines
*
* Borrowed from Moodle code - /admin/uploaduser.php
*/
$data = preg_replace('!\\r\\n?!', "\n", $data);
$fp = fopen($filedata['tmp_name'], 'w');
fwrite($fp, $data);
fclose($fp);
$fp = fopen($filedata['tmp_name'], 'r');
/**
* The required and optional fields we're looking for in the CSV file.
*/
$required = array('studentid' => 1, 'class' => 1, 'trainernum' => 1, 'startdate' => 1, 'enddate' => 1);
$optional = array('firstname' => 1, 'lastname' => 1, 'curriculum' => 1, 'status' => 1, 'completed' => 1, 'grade' => 1, 'frequency' => 1, 'timeperiod' => 1);
$colpos = array();
$header = split($csv_delimiter, fgets($fp, 1024));
// Check for valid field names
foreach ($header as $i => $h) {
$h = trim($h);
$header[$i] = $h;
// remove whitespace
$h = ereg_replace('^\\"|\\"$', '', $h);
// strip encapsulating quotes
$header[$i] = $h;
if (isset($required[$h])) {
$required[$h] = 0;
$colpos[$i] = $h;
} else {
if (isset($optional[$h])) {
$colpos[$i] = $h;
}
}
}
/// Check for required fields
foreach ($required as $key => $value) {
if ($value) {
//required field missing
return get_string('missing_required_field', 'block_curr_admin', $key);
}
}
//.........这里部分代码省略.........