質問編集履歴
1
アドバイスをもとに子プロセスでDB接続
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -72,4 +72,80 @@
|
|
|
72
72
|
$totalAccess = $totalAccess + $i;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
子プロセスでのDB接続を試してみましたがダメでした。
|
|
78
|
+
```php
|
|
79
|
+
for ($i=0; $i < $pcount; $i++) {
|
|
80
|
+
$pid = pcntl_fork();
|
|
81
|
+
if( $pid === -1 ) {
|
|
82
|
+
debug('マルチプロセスのforkに失敗');
|
|
83
|
+
exit;
|
|
84
|
+
}elseif($pid === 0){
|
|
85
|
+
//子プロセス
|
|
86
|
+
if ($i===($pcount-1)) {
|
|
87
|
+
$endPage = ($endPage - $processPage) + $lastProcessPage;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
$page = $startPage;
|
|
91
|
+
|
|
92
|
+
for ($page; $page <= $endPage; $page++) {
|
|
93
|
+
|
|
94
|
+
$result = $CrawlingContent->find('all', array(
|
|
95
|
+
'conditions' => $conditions,
|
|
96
|
+
'recursive' => -1,
|
|
97
|
+
'limit' => $limit,
|
|
98
|
+
'page' => $page,
|
|
99
|
+
));
|
|
100
|
+
foreach ($result as $resultValue) {
|
|
101
|
+
debug($resultValue['CrawlingContent']['url']);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
exit;
|
|
106
|
+
}
|
|
107
|
+
// 親プロセスの処理
|
|
108
|
+
$processes[] = $pid;
|
|
109
|
+
$startPage = $startPage + $processPage;
|
|
110
|
+
$endPage = $endPage + $processPage;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
foreach($processes as $process) {
|
|
114
|
+
pcntl_waitpid($process, $status);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
エラーコード
|
|
118
|
+
```ここに言語を入力
|
|
119
|
+
Warning Error: Packets out of order. Expected 1 received 3. Packet size=262144 in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
120
|
+
|
|
121
|
+
Warning Error: Packets out of order. Expected 4 received 97. Packet size=7496534 in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
122
|
+
|
|
123
|
+
Warning Error: Packets out of order. Expected 1 received 99. Packet size=6621798 in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
124
|
+
|
|
125
|
+
Warning Error: PDOStatement::execute(): MySQL server has gone away in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
126
|
+
|
|
127
|
+
Warning Error: PDOStatement::execute(): MySQL server has gone away in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
128
|
+
|
|
129
|
+
Warning Error: PDOStatement::execute(): MySQL server has gone away in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
130
|
+
|
|
131
|
+
Warning Error: PDOStatement::execute(): Error reading result set's header in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
132
|
+
|
|
133
|
+
Warning Error: PDOStatement::execute(): Error reading result set's header in [/home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php, line 468]
|
|
134
|
+
|
|
135
|
+
Error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
|
|
136
|
+
#0 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php(468): PDOStatement->execute(Array)
|
|
137
|
+
#1 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php(434): DboSource->_execute('SELECT `Crawlin...', Array)
|
|
138
|
+
#2 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php(671): DboSource->execute('SELECT `Crawlin...', Array, Array)
|
|
139
|
+
#3 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/DboSource.php(1120): DboSource->fetchAll('SELECT `Crawlin...', false)
|
|
140
|
+
#4 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Model.php(3038): DboSource->read(Object(CrawlingContent), Array)
|
|
141
|
+
#5 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Model/Model.php(3010): Model->_readDataSource('all', Array)
|
|
142
|
+
#6 /home/scraper/public_html/ec_scraper/Controller/Component/ScrapingComponent.php(1434): Model->find('all', Array)
|
|
143
|
+
#7 /home/scraper/public_html/ec_scraper/Controller/Component/ScrapingComponent.php(36): ScrapingComponent->crawler_index_multi()
|
|
144
|
+
#8 /home/scraper/public_html/ec_scraper/Console/Command/ScraperShell.php(65): ScrapingComponent->test()
|
|
145
|
+
#9 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Console/Shell.php(458): ScraperShell->test()
|
|
146
|
+
#10 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Console/ShellDispatcher.php(212): Shell->runCommand('test', Array)
|
|
147
|
+
#11 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()
|
|
148
|
+
#12 /home/scraper/public_html/ec_scraper/Vendor/cakephp/cakephp/lib/Cake/Console/cake.php(54): ShellDispatcher::run(Array)
|
|
149
|
+
#13 {main}
|
|
150
|
+
|
|
75
151
|
```
|