Zero1_Crondoctor - Version 1.0.11

Version Notes

Zombie Job checker fix

Download this release

Release Info

Developer Arron Moss
Extension Zero1_Crondoctor
Version 1.0.11
Comparing to
See all releases


Code changes from version 1.0.10 to 1.0.11

app/code/community/Zero1/Crondoctor/Model/Observer/Zombie.php CHANGED
@@ -10,7 +10,8 @@ class Zero1_Crondoctor_Model_Observer_Zombie{
10
 
11
  protected $_zombieEmailSubject = 'Magento Cron Doctor Zombie Report';
12
 
13
- public function checkForZombieJobs(Varien_Event_Observer $event){
 
14
  $storeId = Mage::app()->getStore()->getId();
15
  $to = Mage::getStoreConfig(self::XML_PATH_ZOMBIE_EMAIL_TO, $storeId);
16
 
@@ -25,8 +26,13 @@ class Zero1_Crondoctor_Model_Observer_Zombie{
25
  $cronjob_collection->addFieldToFilter('status', array(
26
  'eq' => Mage_Cron_Model_Schedule::STATUS_RUNNING)
27
  );
 
 
 
 
28
 
29
  $job_list_content = '';
 
30
  foreach($cronjob_collection as $cronjob) {
31
  if($cronjob->getReportedAt()) {
32
  continue; // No need to report more then once.
@@ -37,6 +43,7 @@ class Zero1_Crondoctor_Model_Observer_Zombie{
37
  if($running_time >= Mage::getStoreConfig(self::XML_PATH_ZOMBIE_TIME, $storeId)) {
38
  $job_list_content .= '"'.ucwords(str_replace('_', ' ', $cronjob->getJobCode()))."'";
39
  $job_list_content .= ' has been running for '.$running_time.' minutes.<br/>';
 
40
 
41
  $cronjob->setReportedAt(strftime('%Y-%m-%d %H:%M:%S', time()));
42
  $cronjob->save();
@@ -52,7 +59,7 @@ class Zero1_Crondoctor_Model_Observer_Zombie{
52
  ->sendTransactional(
53
  Mage::getStoreConfig(self::XML_PATH_ZOMBIE_EMAIL_TEMPLATE, $storeId),
54
  Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId),
55
- $to,
56
  null,
57
  array(
58
  'subject' => $this->_zombieEmailSubject,
10
 
11
  protected $_zombieEmailSubject = 'Magento Cron Doctor Zombie Report';
12
 
13
+ public function checkForZombieJobs(Varien_Event_Observer $event)
14
+ {
15
  $storeId = Mage::app()->getStore()->getId();
16
  $to = Mage::getStoreConfig(self::XML_PATH_ZOMBIE_EMAIL_TO, $storeId);
17
 
26
  $cronjob_collection->addFieldToFilter('status', array(
27
  'eq' => Mage_Cron_Model_Schedule::STATUS_RUNNING)
28
  );
29
+ // This is in place, because when core "tries to lock job" it only updates the status => running
30
+ // this means that to the zombie checker the job has a state of running and a start time of 0.
31
+ // Giving it a massive run time.
32
+ $cronjob_collection->addFieldToFilter('executed_at', array('notnull' => true));
33
 
34
  $job_list_content = '';
35
+ /** @var Mage_Cron_Model_Schedule $cronjob */
36
  foreach($cronjob_collection as $cronjob) {
37
  if($cronjob->getReportedAt()) {
38
  continue; // No need to report more then once.
43
  if($running_time >= Mage::getStoreConfig(self::XML_PATH_ZOMBIE_TIME, $storeId)) {
44
  $job_list_content .= '"'.ucwords(str_replace('_', ' ', $cronjob->getJobCode()))."'";
45
  $job_list_content .= ' has been running for '.$running_time.' minutes.<br/>';
46
+ //$job_list_content .= 'Data: '.json_encode($cronjob->getData()).'<hr />';
47
 
48
  $cronjob->setReportedAt(strftime('%Y-%m-%d %H:%M:%S', time()));
49
  $cronjob->save();
59
  ->sendTransactional(
60
  Mage::getStoreConfig(self::XML_PATH_ZOMBIE_EMAIL_TEMPLATE, $storeId),
61
  Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId),
62
+ explode(',', $to),
63
  null,
64
  array(
65
  'subject' => $this->_zombieEmailSubject,
app/code/community/Zero1/Crondoctor/Model/Schedule.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- class Zero1_Crondoctor_Model_Schedule extends Mage_Cron_Model_Schedule{
3
-
4
  protected function _beforeSave(){
5
  parent::_beforeSave();
6
  $this->setUpdatedAt(strftime('%Y-%m-%d %H:%M:%S', time()));
1
  <?php
2
+ class Zero1_Crondoctor_Model_Schedule extends Mage_Cron_Model_Schedule
3
+ {
4
  protected function _beforeSave(){
5
  parent::_beforeSave();
6
  $this->setUpdatedAt(strftime('%Y-%m-%d %H:%M:%S', time()));
app/code/community/Zero1/Crondoctor/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Zero1_Crondoctor>
5
- <version>1.0.10</version>
6
  </Zero1_Crondoctor>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Zero1_Crondoctor>
5
+ <version>1.0.11</version>
6
  </Zero1_Crondoctor>
7
  </modules>
8
 
app/code/community/Zero1/Crondoctor/moduleDescription.html ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <p>This extension allows you to see all required information for the essential Cron system which runs all Magentos
3
+ scheduled tasks. Often there can be failures with code or processes, timeouts, memory errors or issues with
4
+ third-party modules causing the Cron system to block up. </p>
5
+
6
+ <h3>Extension features:</h3>
7
+ <ul>
8
+ <li>View the complete cron schedule of tasks.</li>
9
+ <li>Delete Cron entries - useful where process are stuck at processing.</li>
10
+ <li>Check execution times</li>
11
+ <li>View all errors produced by any cron tasks.</li>
12
+ </ul>
13
+ <p>Please email your questions and suggestions via <a href="https://zero1limited.zendesk.com/home">https://zero1limited.zendesk.com/home</a>
14
+ or send us a PM at Magento site. Feedback is very welcome.</p>
15
+ </div>
16
+ <div>
17
+ <h2>Install Instructions</h2>
18
+ <ol>
19
+ <li>Stop magento core cron, you can do this via either stop the crond service or simply commenting out the relative
20
+ line in your cron tab
21
+ </li>
22
+ <li>
23
+ wait for all cron processes to finish<br/>
24
+ <pre>watch -n1 "ps aux | grep cron.php | grep -v grep"</pre>
25
+ <br/>
26
+ </li>
27
+ <li>Install the module as normal, via FTP/Git/MCM</li>
28
+ <li>Flush both caches</li>
29
+ <li>
30
+ Alter the following configuration options:<br />
31
+ &nbsp;System - Configuration - Advanced | System - Cron<br />
32
+ &nbsp;&nbsp;- "Generate Schedules Every" = 15<br />
33
+ &nbsp;&nbsp;- "Schedule Ahead for" = 20<br />
34
+ &nbsp;&nbsp;- "Missed if Not Run Within" = 0<br />
35
+ &nbsp;&nbsp;- "History Cleanup Every" = [AS DESIRED]<br />
36
+ &nbsp;&nbsp;- "Success History Lifetime" = [AS DESIRED]<br />
37
+ &nbsp;&nbsp;- "Failure History Lifetime" = [AS DESIRED]<br />
38
+ </li>
39
+ <li>Alter your cron job to point to "zero1/cron.php", and restart crond if needed</li>
40
+ <li>
41
+ confirm jobs are running<br/>
42
+ <pre>watch -n1 "ps aux | grep cron.php | grep -v grep"</pre>
43
+ <br />
44
+ on the minute you should see jobs ending with the following:<br />
45
+ &nbsp;&nbsp;-mdefault<br />
46
+ &nbsp;&nbsp;-malways<br />
47
+ &nbsp;&nbsp;-schedule<br />
48
+ &nbsp;&nbsp;-zombie<br />
49
+ </li>
50
+ </ol>
51
+ <hr/>
52
+ </div>
53
+ <div>
54
+ <h2>Misc</h2>
55
+ <h3>Stopping/Starting Cron after installation</h3>
56
+ If you need to stop cron, from the root of your magento installation:<br/>
57
+ <pre>touch zero1/cron_stop.flag</pre><br/>
58
+ <pre>watch -n1 "ps aux | grep cron.php | grep -v grep"</pre><br/>
59
+ wait until all jobs are finished.<br/>
60
+ To restart cron:<br/>
61
+ <pre>rm zero1/cron_stop.flag</pre><br/>
62
+ you should then be able to see all jobs restarting
63
+ <hr/>
64
+ <h3>Disaster Recover</h3>
65
+ If cron is stopped with the cron_stop.flag being in place, then you could end up with jobs the are permanently running.
66
+ This can be observed by going to System > Cron Doctor and checking filtering by status = 'running' if there are more than 2 jobs running there is an issue.
67
+ <br/>
68
+ <b>enterprise_refresh_index</b>: is an 'always' job, if this job hasn't ran since cron has been started again i.e status == running and executed_at is before cron was stopped, the status of this job will need changing (to anything but 'running')
69
+ <br/>
70
+ Every other job is the same principle as enterprise_refresh_index.
71
+
72
+ N.B you should expect 0 - 2 jobs running at anyone time if there are 2 jobs running 1 of them should be enterprise_refresh_index, if this is not the case there is an issue.
73
+ <hr/>
74
+ </div>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Zero1_Crondoctor</name>
4
- <version>1.0.10</version>
5
  <stability>stable</stability>
6
  <license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
9
  <summary>Crondoctor</summary>
10
  <description>Crondoctor&#xD;
11
  </description>
12
- <notes>ACL issue fix</notes>
13
  <authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
14
- <date>2016-03-08</date>
15
- <time>09:28:41</time>
16
- <contents><target name="magecommunity"><dir name="Zero1"><dir name="Crondoctor"><dir name="Block"><dir name="Adminhtml"><dir name="Crondoctor"><file name="Grid.php" hash="ff758796ef8d66b388e0b1d60d73f92e"/><file name="Notice.php" hash="6b4c20f69f875fa3410a34acc8d2209a"/></dir><file name="Crondoctor.php" hash="6fa8fd6eee1dd35d9b82f861238738c1"/><dir name="Visual"><file name="Form.php" hash="2df5703fc827781478fd07d1e28296a5"/><file name="Lag.php" hash="533573979e5c75c7f99b9a0a81cafbf1"/><file name="Visual.php" hash="48d7f42c7469621307134e864033ef1b"/></dir><file name="Visual.php" hash="2b2f08b18ca4c97716bfb9a3cb16c92c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4b85072f6909ba3f083c99814103a92a"/></dir><dir name="Model"><dir name="Observer"><file name="Zombie.php" hash="325e2b06c599fba12377f5be17738299"/></dir><file name="Observer.php" hash="be0e3653a5187ac5723386f6033f88a1"/><dir name="Schedule"><dir name="Job"><file name="Process.php" hash="57cf2b34b80024af1090e6f5e46c170f"/></dir><file name="Job.php" hash="2f2df91e0aa5f628aa196586d3d4c568"/></dir><file name="Schedule.php" hash="a3f86374eab1771d844a84c9184f3bbe"/><dir name="Visual"><dir name="Schedule"><dir name="Job"><file name="Process.php" hash="4d0b95ec31c3c7b7fcba86ff89159dc6"/></dir><file name="Job.php" hash="c2ea122f797ca735de59cfd1ff9bfc96"/></dir><file name="Schedule.php" hash="f5e4e64b1fe0ccb6bdd3ef380496e2b3"/></dir></dir><file name="README.md" hash="c1514c3ca5f67fefee310915c99e7772"/><dir name="controllers"><dir name="Adminhtml"><dir name="Crondoctor"><file name="VisualController.php" hash="935cb373b65cc193cb6740ab4a140495"/></dir><file name="CrondoctorController.php" hash="fef96b78d8443ed6494a3b19affed8ec"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b32ed969146550cc2a98d4b133eb4543"/><file name="config.xml" hash="30009266047b8057de21eba9e7de1ab1"/><file name="system.xml" hash="b6251a8f7b3ff0a63241d6d421e59eaf"/></dir><dir name="sql"><dir name="zero1_crondoctor_setup"><file name="install-1.0.0.php" hash="af6b55e68b5c327efcf58452719d359e"/><file name="mysql4-install-1.0.0.php" hash="af6b55e68b5c327efcf58452719d359e"/><file name="upgrade-1.0.7-1.0.8.php" hash="4431ab57cc541f82a75734eefa8e494a"/><file name="upgrade-1.0.8-1.0.9.php" hash="a72fda900430ce3cde8cc6e636138ecb"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zero1_Crondoctor.xml" hash="3ccefc4ae6efeecc2bfd7df6a59264f1"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="crondoctor"><file name="crondoctor.xml" hash="3ec02e0cf305a7bd347c78a8420e799f"/></dir></dir><dir name="template"><dir name="crondoctor"><file name="notice.phtml" hash="95575d8f09e623c05c0de950677346ce"/><dir name="visual"><file name="container.phtml" hash="5242e2d186173d5b3bf779b1f14024c8"/><file name="visual.phtml" hash="d9f16c4ac6d847846335b494b39c0169"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="crondoctor_zombieemail.html" hash="ad7b0695ba42ddaea95e50b8d9859370"/></dir></dir></dir></target><target name="mage"><dir name="zero1"><file name="cron.php" hash="dc8160c75340b38bc5b1554d7a0bf0e2"/><file name="cron.sh" hash="c752a6d282579c3f2ed2e7a2e5864f28"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Zero1_Crondoctor</name>
4
+ <version>1.0.11</version>
5
  <stability>stable</stability>
6
  <license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
7
  <channel>community</channel>
9
  <summary>Crondoctor</summary>
10
  <description>Crondoctor&#xD;
11
  </description>
12
+ <notes>Zombie Job checker fix</notes>
13
  <authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
14
+ <date>2016-05-23</date>
15
+ <time>07:12:06</time>
16
+ <contents><target name="magecommunity"><dir name="Zero1"><dir name="Crondoctor"><dir name="Block"><dir name="Adminhtml"><dir name="Crondoctor"><file name="Grid.php" hash="ff758796ef8d66b388e0b1d60d73f92e"/><file name="Notice.php" hash="6b4c20f69f875fa3410a34acc8d2209a"/></dir><file name="Crondoctor.php" hash="6fa8fd6eee1dd35d9b82f861238738c1"/><dir name="Visual"><file name="Form.php" hash="2df5703fc827781478fd07d1e28296a5"/><file name="Lag.php" hash="533573979e5c75c7f99b9a0a81cafbf1"/><file name="Visual.php" hash="48d7f42c7469621307134e864033ef1b"/></dir><file name="Visual.php" hash="2b2f08b18ca4c97716bfb9a3cb16c92c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4b85072f6909ba3f083c99814103a92a"/></dir><dir name="Model"><dir name="Observer"><file name="Zombie.php" hash="8194f6554b1b04b7a7c72828e35ca1a5"/></dir><file name="Observer.php" hash="be0e3653a5187ac5723386f6033f88a1"/><dir name="Schedule"><dir name="Job"><file name="Process.php" hash="57cf2b34b80024af1090e6f5e46c170f"/></dir><file name="Job.php" hash="2f2df91e0aa5f628aa196586d3d4c568"/></dir><file name="Schedule.php" hash="a27fd3332f314d812637237069599e62"/><dir name="Visual"><dir name="Schedule"><dir name="Job"><file name="Process.php" hash="4d0b95ec31c3c7b7fcba86ff89159dc6"/></dir><file name="Job.php" hash="c2ea122f797ca735de59cfd1ff9bfc96"/></dir><file name="Schedule.php" hash="f5e4e64b1fe0ccb6bdd3ef380496e2b3"/></dir></dir><file name="README.md" hash="c1514c3ca5f67fefee310915c99e7772"/><dir name="controllers"><dir name="Adminhtml"><dir name="Crondoctor"><file name="VisualController.php" hash="935cb373b65cc193cb6740ab4a140495"/></dir><file name="CrondoctorController.php" hash="fef96b78d8443ed6494a3b19affed8ec"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b32ed969146550cc2a98d4b133eb4543"/><file name="config.xml" hash="7b6ae9d1386b8101c765c791bcedb742"/><file name="system.xml" hash="b6251a8f7b3ff0a63241d6d421e59eaf"/></dir><file name="moduleDescription.html" hash="d741cdb3830c01519142188f77e5be0c"/><dir name="sql"><dir name="zero1_crondoctor_setup"><file name="install-1.0.0.php" hash="af6b55e68b5c327efcf58452719d359e"/><file name="mysql4-install-1.0.0.php" hash="af6b55e68b5c327efcf58452719d359e"/><file name="upgrade-1.0.7-1.0.8.php" hash="4431ab57cc541f82a75734eefa8e494a"/><file name="upgrade-1.0.8-1.0.9.php" hash="a72fda900430ce3cde8cc6e636138ecb"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zero1_Crondoctor.xml" hash="3ccefc4ae6efeecc2bfd7df6a59264f1"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="crondoctor"><file name="crondoctor.xml" hash="3ec02e0cf305a7bd347c78a8420e799f"/></dir></dir><dir name="template"><dir name="crondoctor"><file name="notice.phtml" hash="95575d8f09e623c05c0de950677346ce"/><dir name="visual"><file name="container.phtml" hash="5242e2d186173d5b3bf779b1f14024c8"/><file name="visual.phtml" hash="d9f16c4ac6d847846335b494b39c0169"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="crondoctor_zombieemail.html" hash="ad7b0695ba42ddaea95e50b8d9859370"/></dir></dir></dir></target><target name="mage"><dir name="zero1"><file name="cron.php" hash="dc8160c75340b38bc5b1554d7a0bf0e2"/><file name="cron.sh" hash="c752a6d282579c3f2ed2e7a2e5864f28"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>