折腾:
【未解决】lnmp中php警告:wp-cron.php execution timed out terminating
期间,需要搞清楚,对于php的slow的log中所反映出的evernote-sync的死掉的位置时候输出:
[15-Sep-2017 21:15:56] [pool www] pid 2712 script_filename = /home/wwwroot/www.crifan.com/wp-cron.php [0x00007f36452d7c60] fopen() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Thrift/Transport/THttpClient.php:207 [0x00007f36452d7ae0] flush() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/EDAM/NoteStore/NoteStore.php:3908 [0x00007f36452d79b8] send_listSharedNotebooks() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/EDAM/NoteStore/NoteStore.php:3890 [0x00007fff0fa03380] listSharedNotebooks() unknown:0 [0x00007f36452d7858] invokeArgs() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Store/Store.php:25 [0x00007fff0fa036f0] __call() unknown:0 [0x00007f36452d7708] listSharedNotebooks() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Client.php:354 [0x00007f36452d7508] listSharedNotebooks() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Client.php:247 [0x00007f36452d73b8] listNotebooks() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Client.php:971 [0x00007f36452d7220] findNotes_listNotebooksWithContext() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Client.php:807 [0x00007f36452d7078] findNotesWithSearch() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/EvernoteSync.php:506 [0x00007f36452d6db8] searchNotes() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/evernote-sync.php:93 [0x00007f36452d6c88] sync() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/evernote-sync.php:565 [0x00007fff0fa042f0] evernote_sync_task() unknown:0 [0x00007f36452d6b40] call_user_func_array() /home/wwwroot/www.crifan.com/wp-includes/class-wp-hook.php:298 [0x00007f36452d6a10] apply_filters() /home/wwwroot/www.crifan.com/wp-includes/class-wp-hook.php:323 [0x00007f36452d68d8] do_action() /home/wwwroot/www.crifan.com/wp-includes/plugin.php:515 [0x00007f36452d6778] do_action_ref_array() /home/wwwroot/www.crifan.com/wp-cron.php:117 |
对应着源码的地方是哪里,以及调用的顺序。
evernote-sync github
Evernote Sync — WordPress Plugins
jicksta/sync-evernote: Dockerized Evernote synchronizer
别人写了个sync的工具,但不是我要的。
evernote/evernote-thrift: Thrift IDL files for the Evernote Cloud API
Documentation – Evernote Developers
下载了源码:
https://downloads.wordpress.org/plugin/evernote-sync.zip
去看看
确认了,代码是由下往上的调用的
至少是:
[0x00007f36452d7220] findNotes_listNotebooksWithContext() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Client.php:807
-》
[0x00007f36452d73b8] listNotebooks() /home/wwwroot/www.crifan.com/wp-content/plugins/evernote-sync/src/Evernote/Client.php:971
最后卡死在:
/** * Opens and sends the actual request over the HTTP connection * * @throws TTransportException if a writing error occurs */ public function flush() { 。。。 $contextid = stream_context_create(array(‘http’ => $options)); $this->handle_ = @fopen($this->scheme_.’://’.$host.$this->uri_, ‘r’, false, $contextid); |
也是
https://github.com/Automattic/php-thrift-sql/blob/master/src/Thrift/Transport/THttpClient.php
看到的那样。
后来去搜:
listSharedNotebooks send_listSharedNotebooks
【总结】
最后几步的代码调用分别是:
/Users/crifan/dev/dev_root/crifan.com/evernote-sync/evernote-sync/src/EDAM/NoteStore/NoteStore.php
public function listSharedNotebooks($authenticationToken) { $this->send_listSharedNotebooks($authenticationToken); return $this->recv_listSharedNotebooks(); } public function send_listSharedNotebooks($authenticationToken) { $args = new \EDAM\NoteStore\NoteStore_listSharedNotebooks_args(); $args->authenticationToken = $authenticationToken; $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists(‘thrift_protocol_write_binary’); if ($bin_accel) { thrift_protocol_write_binary($this->output_, ‘listSharedNotebooks’, TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); } else { $this->output_->writeMessageBegin(‘listSharedNotebooks’, TMessageType::CALL, $this->seqid_); $args->write($this->output_); $this->output_->writeMessageEnd(); $this->output_->getTransport()->flush(); } } |
/Users/crifan/dev/dev_root/crifan.com/evernote-sync/evernote-sync/src/Thrift/Transport/THttpClient.php
/** * Opens and sends the actual request over the HTTP connection * * @throws TTransportException if a writing error occurs */ public function flush() { // God, PHP really has some esoteric ways of doing simple things. $host = $this->host_.($this->port_ != 80 ? ‘:’.$this->port_ : ”); $headers = array(); $defaultHeaders = array(‘Host’ => $host, ‘Accept’ => ‘application/x-thrift’, ‘User-Agent’ => ‘PHP/THttpClient’, ‘Content-Type’ => ‘application/x-thrift’, ‘Content-Length’ => TStringFuncFactory::create()->strlen($this->buf_)); foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) { $headers[] = "$key: $value"; } $options = array(‘method’ => ‘POST’, ‘header’ => implode("\r\n", $headers), ‘max_redirects’ => 1, ‘content’ => $this->buf_); if ($this->timeout_ > 0) { $options[‘timeout’] = $this->timeout_; } $this->buf_ = ”; $contextid = stream_context_create(array(‘http’ => $options)); $this->handle_ = @fopen($this->scheme_.’://’.$host.$this->uri_, ‘r’, false, $contextid); // Connect failed? if ($this->handle_ === FALSE) { $this->handle_ = null; $error = ‘THttpClient: Could not connect to ‘.$host.$this->uri_; throw new TTransportException($error, TTransportException::NOT_OPEN); } } |