druapl Cron run failed
八 31st
一个新闻资讯类的新站采用drupal驱动,使用了其上的openpublish集成安装包,在增加了xmlsitemap后提示Cron run failed. 在drupal内置的recent log entries中显示
Attempting to re-run cron while it is already running.
以及在每隔一个小时显示:
Cron has been running for more than an hour and is most likely stuck.
无解,求助google,终于找到:
cron函数的定义在includes/common.inc中function drupal_cron_run(){} 简单的解决方式是在运行corn前删除semaphore值,使cron解锁。如下:
function drupal_cron_run() {
// If not in 'safe mode', increase the maximum execution time:
variable_del('cron_semaphore');
并且一些log记录:完整修改drupal_cron_run()代码如下(修改处用粗体表示):
function drupal_cron_run() {
// If not in ‘safe mode’, increase the maximum execution time:
variable_del(‘cron_semaphore’);
if (function_exists(‘set_time_limit’)) {
@set_time_limit(240);
}// Fetch the cron semaphore
$semaphore = variable_get(‘cron_semaphore’, FALSE);
if ($semaphore) {
if (time() – $semaphore > 3600) {
// Either cron has been running for more than an hour or the semaphore
// was not reset due to a database error.
watchdog(‘cron’, t(‘Cron has been running for more than an hour and is most likely stuck.’), WATCHDOG_ERROR);
// Release cron semaphore
variable_del(‘cron_semaphore’);
}
else {
// Cron is still running normally.
watchdog(‘cron’, t(‘Attempting to re-run cron while it is already running.’), WATCHDOG_WARNING);
}
}
else {
// Register shutdown callback
register_shutdown_function(‘drupal_cron_cleanup’);
// Lock cron semaphore
variable_set(‘cron_semaphore’, time());
// Iterate through the modules calling their cron handlers (if any):
// module_invoke_all(‘cron’);
$log_timing = variable_get(‘cron_log_times’, ’1′);
foreach (module_implements(‘cron’) as $module) {
watchdog(‘cron’, t(‘Cron processing initiated for module: @module.’, array(‘@module’ => $module)));
if ($module == “search”) continue;
$function = $module .’_cron’;
if ($log_timing) {
timer_start($function);
if ($log_timing == ‘debug’) {
watchdog(‘cron’, t(‘Cron processing initiated for module: @module.’, array(‘@module’ => $module)));
}
}
$function();
if ($log_timing) {
$timer = timer_stop($function);
watchdog(‘cron’, t(‘Cron time elapsed for @module is @millisecs ms.’, array(‘@module’ => $module, ‘@millisecs’ => $timer['time'])));
}
}
// Record cron time
variable_set(‘cron_last’, time());
watchdog(‘cron’, t(‘Cron run completed.’), WATCHDOG_NOTICE);
// Release cron semaphore
variable_del(‘cron_semaphore’);
// Return TRUE so other functions can check if it did run successfully
return TRUE;
}
}
/**
* Executes a cron run when called
* @return
* Returns TRUE if ran successfully
*/
function drupal_cron_run() {
// If not in 'safe mode', increase the maximum execution time:
variable_del('cron_semaphore');
if (!ini_get('safe_mode')) {
set_time_limit(240);
} // Fetch the cron semaphore
$semaphore = variable_get('cron_semaphore', FALSE);
if ($semaphore) {
if (time() - $semaphore > 3600) {
// Either cron has been running for more than an hour or the semaphore
// was not reset due to a database error.
watchdog('cron', t('Cron has been running for more than an hour and is most likely stuck.'), WATCHDOG_ERROR);
// Release cron semaphore
variable_del('cron_semaphore');
}
else {
// Cron is still running normally.
watchdog('cron', t('Attempting to re-run cron while it is already running.'), WATCHDOG_WARNING);
}
}
else {
// Register shutdown callback
register_shutdown_function('drupal_cron_cleanup');
// Lock cron semaphore
variable_set('cron_semaphore', time());
// Iterate through the modules calling their cron handlers (if any):
// module_invoke_all('cron');
$log_timing = variable_get('cron_log_times', '1');
foreach (module_implements('cron') as $module) {
watchdog('cron', t('Cron processing initiated for module: @module.', array('@module' => $module)));
if ($module == "search") continue;
$function = $module .'_cron';
if ($log_timing) {
timer_start($function);
if ($log_timing == 'debug') {
watchdog('cron', t('Cron processing initiated for module: @module.', array('@module' => $module)));
}
}
$function();
if ($log_timing) {
$timer = timer_stop($function);
watchdog('cron', t('Cron time elapsed for @module is @millisecs ms.', array('@module' => $module, '@millisecs' => $timer['time'])));
}
}
// Record cron time
variable_set('cron_last', time());
watchdog('cron', t('Cron run completed.'), WATCHDOG_NOTICE);
// Release cron semaphore
variable_del('cron_semaphore');
// Return TRUE so other functions can check if it did run successfully
return TRUE;
}
}
原文来自:http://www.ebizontek.com/drupal-cron-stuck-log-progress
mysql repair
八 27th
备份mysql时出错:
mysqldump: Error 1194: Table ‘wp_options’ is marked as crashed and should be repaired when dumping table `wp_options` at row: 91
所需要的是进行数据库修复操作
解决方法:
进入mysql控制台:
mysql -u usename -p password
use databasename;
repair tablename;
问题解决:
mysql> repair table wp_options;
+——————–+——–+———-+—————————————————–+
| Table | Op | Msg_type | Msg_text |
+——————–+——–+———-+—————————————————–+
| dengruo.wp_options | repair | info | Found block with too small length at 12084; Skipped |
| dengruo.wp_options | repair | warning | Number of rows changed from 398 to 397 |
| dengruo.wp_options | repair | status | OK |
+——————–+——–+———-+—————————————————–+
3 rows in set (1.26 sec)
如果有phpmyadmin的话直接有个修复数据选项可以操作。
ps:Mysql控制台的命令需要后面加上’;’
nginx+mysql+php-fpm
八 27th
几天时间:一直耗在nginx+mysql+php-fpm的配置中
将网上能够google到的方法几乎都尝试了遍。
最终成功的只有linode的教学资料里面的和张宴的第六版的方法。
linode的方法是直接rpm的,简单稳定,但是组件太老了–对于类似我之类的liunx新手而言,是一个不错的学习文档。
本站还是在apache和nginx之间徘徊。
一个老大粗笨但是支持全而,webmin面板就能让人省很多事。
一个新锐蓬勃,但是有用的文档都是英文的(好像基本上技术类的文档中文的都是毫无价值,除了偶尔的)。
发现个不错的rpm: http://iuscommunity.org/
CentOS官方wiki对它的介绍:
http://wiki.centos.org/AdditionalResources/Repositories
继续reload VPS去,争取把php换成5.3.3版本。
备注下:linode 的VPS 设置PPTP时的默认的kernel 有问题的,要切换成stable版本的。
wordpress英文版在升级后有提示要升级数据库的,为什么今天升级本博客时用的中文版没有相应提示呢?
drupal imce上传文件按时间归类
八 22nd
drupal imce 上传的文件默认是全部放在files下面。时间长了对管理很不方便。
将上传的文档图片按照文件进行归类。
1:进入imce的管理界面:admin/settings/imce。默认有两个profile,我选择了直接编辑其中的User-1。
这里面可以设置图片的大小,所有用户的总的上传量之类的数据,但是对于对于这个主题而言最主要的地方在于:
设置目录路径。这里面可以直接输入php代码来实现自己的功能。但是前面要加上php:因为站点现在的图片量不是很大,所以只进行了年月的分类,而没有精确到日。示例如下:
php: return date(‘Y’, $user->created).’/’.date(‘m’, $user->created);
减少Disk IO
八 19th
被服务器搞的心烦,除了mysql的500外,disk IO数值居高不下。
google了相关资料,整理下:
1:控制系统内存swap的概率。最直接的是关掉swap,但是这种突发状况下内存不够,修改swappiness参数到0,尽可能地使用物理内存而不是虚拟内存。遗憾的是我的物理内存总是满的,还是想办法减小分配给缓存的内存了。
查看命令
sysctl -q vm.swappiness
默是60
修改命令sudo sysctl vm.swappiness=10
2:调整Apache的MaxRequestsPerChild,据说对disk IO的影响很明显。先测试上面的再进行这个测试了。不过说这个处理数下降了,各方面都肯定会降的,但是因此影响到了网站的同时在线承受能力就得之东隅,失之西隅了。
我的脚
八 1st
白天china joy,晚上世博,在連續17個小時的站著,走著–就是沒有坐著後,徹底地萎掉了。
总而言之:china joy的门票虽然比世博贵,但是价值也较高。
世博他妈的就是一鸡肋,“总得去次吧”,盛名之下,焉负其实。除了拍张照,进行类似孙大圣撒泡尿到此一游的行为别无乐趣。
ps:
晚上去吧,雨天也不错。看到中国馆坚持走开,基本上没希望进去。而且也别指望你的同类会有什么创意,不信你可以去中国省市联合馆见识一下LED显示屏,除了看视频就没东西了。
芬兰馆的门口的美女不错。轮到我们时刚好把我们拦下,
我说了声:人品不行。
金发美女回了句:这就是命运!
和她聊下去还是挺有意思的。调侃她还是挺有意思,希望你有这个运气。
马来西亚的Logo在某些角度看时很像马桶两个字。
——————————————————
为什么我没碰到凤姐?也没找出小苍井空呢不过几百位美女在面前晃来晃去的情况下,原谅我吧。
对show girl身高要求不怎么样的china joy很适合俺们这种只有170身高的人去看–不会自悲,甚至学着地精的话说:天呐,你真高!
咱吃不到葡萄,那就看看吧……
——————————————————
可惜china joy没了,世博还在继续……
可惜我的脚持续疼痛中……
wordpress采集插件tiger
七 16th
没事就喜欢折腾:放出最新wordpress采集插件。
取名为tiger,源于,今年是本命年–虎年,另外么,既然是采集了,咱也别说高尚了,学小日子本发出’hu,hu,hu!’,扑向珍珠港,扑向万恶的资本主义。
———–邪恶的分割线————————
1:解决了标题重复功能
2:针对雅虎问答的最近改版改进了,依旧没有使用yahoo api.
3:版面重新编排,写的时候懒的切换输出法,所以满屏都是chinglish.
4:除了yahoo answer外,新增加了一个采集源ezine.请自行看ezinearticles.com看版权问题,
5:翻译部分解决了采用了新的php translate wagger,其解决了5000字的限制。但是翻译和采集源之间的关系处理一直没有一个比较好的思路去实现。比如yahoo answer,和ezine的是否都需要翻译。所以暂时增加翻译只有一个步骤。
6:前一个tiger版权的数据库可以自动升级。
7:支持wordpress3.0
8:显示的采集数量为尝试采集的次数,在没有找到解决mysql使用负载前暂时不进行log统计。
———–邪恶的分割线————————
1:采集时间的设定,避免访问高峰期
2:作为一贯传承的风格风格,
3:批量增加关键词功能
4:因为是全新的构架,后期可以实现接口连接模块功能,但是依旧没有处理好feeds采集和其它采集源之间在程序构架上面的关系。不排除后期单独将feeds采集写成一个插件的形式。
5:代理设置
6:伪原创和文章的可读性的平衡
大家谁有这些实现的资料,小生在此求教了。
———–邪恶的分割线————————
权且当成测试吧。虽然也可以用于实际生产环境了。以后整体框架应该不会去变动了。敬请期待更加完善的版权的出现,免费的将只提供现有的这两个采集源,收费方式在于定制其它文章站、新闻站的采集源。
运行环境,wamp和lamp下,wordpress3.0下运行无问题。
请测试php-curl,php-dom组件的安装。