This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assume getData to be an API call | |
console.log("Getting Data1"); | |
var data1 = getData('123'); | |
console.log("Data is:", data1); | |
console.log("Getting Data2"); | |
var data2 = getData('456'); | |
console.log("Data is:", data2); | |
var sum = 1 + 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Getting Data1"); | |
getData('123', function(data1) { | |
console.log("Data is:", data1); | |
}); | |
console.log("Getting Data2"); | |
getData('456', function(data1) { | |
console.log("Data is:", data1); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install percona-toolkit | |
pt-online-schema-change --alter | |
"Add column <new_column> varchar(60) NOT NULL default <default_value>" | |
--user=root D=<database_name>,t=<table_name> --execute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return Integer | |
*/ | |
public function getProcessId() | |
{ | |
return getmypid(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return boolean | |
*/ | |
public function isProcessRunning($pid) | |
{ | |
if (file_exists("/proc/".$pid)) { | |
return true; | |
} else { | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param Integer $pid | |
* | |
* @return boolean | |
*/ | |
public function isProcessRunning($pid) | |
{ | |
if (file_exists("/proc/".$pid)) { | |
return true; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param Integer $pid | |
* | |
* @return boolean | |
*/ | |
public function isProcessRunning($pid) | |
{ | |
if (file_exists("/proc/".$pid)) { | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Class LockHandlerUtil | |
*/ | |
class LockHandlerUtil | |
{ | |
/** | |
* @param String $fileName | |
* @param String $rootDir | |
*/ | |
public function __construct($fileName, $rootDir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->lockHandlerUtil = new LockHandlerUtil( | |
$this->getName(), | |
$this->getContainer()->get('kernel')->getRootDir() | |
); | |
// $this->getName() will return the current file name | |
// of the Command (Cron) in Symfony framework. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($this->lockHandlerUtil->isDuplicateInstanceRunning()) { | |
// trigger some kind of alert | |
return; | |
} | |
/* | |
actual cron code | |
.... | |
.... | |
*/ |
OlderNewer