代码如诗
代码如诗seo and sem also website.网站建设,搜索引擎优化及其它。另外包括google adsense
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的影响很明显。先测试上面的再进行这个测试了。不过说这个处理数下降了,各方面都肯定会降的,但是因此影响到了网站的同时在线承受能力就得之东隅,失之西隅了。
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组件的安装。
树德无敌刷团宏
六 25th
声明:树德并没有无敌……
——–标题的意思无非是用了这个宏在25团可以大量地提升治疗量,当然:手法和意识的因素除外。
缘:对于树德而言,网上通常流行两个宏。
A:为结合野性痊愈和回春术的,每6秒释放一次野性,缺点是必须要选中目标才能施法。
B:是只需要将鼠标移至目标便可按宏对其释放技能,但是只有回春术。
玩台服是件痛苦的事,不在于每次打完副本后说安安,在于相对国服更糟糕的网络。对于A而言,在icc,toc等25人本时,无法确认是否已经已经鼠标左键选中,以及是否顺利施法。而B也有同样的问题,野性痊愈在整个树德的输出中占了15%到20%,如何将其囊括到宏中以便实现无脑输出是个问题。
由:在历经N次尝试后,终于,等到了这个机会(晕,弄成NPC台词了)。终于成功了。
本:宏如下:
————————————-
#showtooltips
/castsequence [@mouseover,nomodifier:ctrl,nomodifier:alt] reset=6/combat 回春術,回春術,野性痊癒,回春術,回春術,回春術
/cast [@mouseover,nomodifier:ctrl,nomodifier:alt] 回春術
————————————-
国服的话应该把繁体弄成简体的相应技能。
果:配合grid插件是一个很好很强大的组合,你所要做的只是在grid上面移动鼠标(不需要点击选中),然后很傻很天真地隔一秒按一次宏就OK了。在25icc中顺利拿到治疗第一并开始打酱油。其优点在于减少了50%的操作量,加上网络因素的影响,治疗量的提升在25%到50%左右。副作用是适应时间在一个副本CD,另外容易让人在游戏时睡着。
google adsense的匹配
六 23rd
一直认为google adsense的匹配是与网页内容有关的,但是在firefox下搜索关键词后发现google adsense的广告出现了相关的关键词
![]()
在上图搜索后,下图的google ads出现了相关的广告:

是否可以认为:google工具栏,google的网页搜索等相关服务会收集用户数据并影响内容匹配。
对于:用户隐私的相关问题如何解决?而google的庞大用户群体是否意味着他可以根据这些数据制定相关战略来猎取最大利益?
wordpress全新采集插件tiger alpha版本公布测试
五 14th
wordpress全新采集插件tiger alpha版本公布测试
feature:
tiger 1.0 alpha
模块化设计,便于后期整合。
以插件形式放于modules子文件夹内,
目前主要的子插件为老版本的yahoo answer采集、翻译以及feeds整合。
1:ya采集部分暂时未使用yahoo的api接口,后期考虑修改。
2:翻译目前支持翻成四种语言,可以选择全部输出或者只输出最后一种语言。
3:feeds整合部分的翻译功能暂时写死,无论采集的原文是何种语言,进行自动判断并输出英文。
3:因为测试中,代码中有很多语言并未优化,可能造成较高的内存占用。
4: 测试版本可以自由开发演绎。
5:以后通用版本的重点开发在feeds模块,
6:如果有兴趣者多,准备写下api文档。
7:参照了众多wp的采集类插件并抄了不少代码,@_@,翻译部分采用了Google Translation PHP wrapper;在于表示专心的感谢。
!全部功能处于测试阶段,不能用于现实生产环境。
ps: alpha版本主要为功能测试,界面中只有增加关键词/feeds url选项,而无修改,删除。
不保证正式版本对此版本的数据提供升级维护
我只是个卖菜刀的,至于你拿菜刀去杀人还是杀猪我管不了,由此带来的一系列问题请自负–使用条款只有这么一条
开发环境为php5.2.11 mysql3.0+,
任何疑问请直接留言,但是不保证正式版本的公布时间。
插件下载地址tiger

