|
|
|
@ -50,15 +50,32 @@ if (false === sem_acquire($semaphore, true)) {
@@ -50,15 +50,32 @@ if (false === sem_acquire($semaphore, true)) {
|
|
|
|
|
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD); |
|
|
|
|
|
|
|
|
|
// CLI begin |
|
|
|
|
if (empty($argv[1])) $argv[1] = 'help'; |
|
|
|
|
if (!empty($argv[1])) { |
|
|
|
|
|
|
|
|
|
switch ($argv[1]) { |
|
|
|
|
|
|
|
|
|
case 'crontab': |
|
|
|
|
case 'db': |
|
|
|
|
|
|
|
|
|
if (empty($argv[2])) { |
|
|
|
|
|
|
|
|
|
CLI::danger(_('crontab method requires action argument')); |
|
|
|
|
switch ($argv[2]) { |
|
|
|
|
|
|
|
|
|
case 'optimize': |
|
|
|
|
|
|
|
|
|
CLI::notice(_('optimize database tables...')); |
|
|
|
|
|
|
|
|
|
$db->optimize(); |
|
|
|
|
|
|
|
|
|
CLI::success(_('tables successfully optimized!')); |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case 'crontab': |
|
|
|
|
|
|
|
|
|
if (empty($argv[2])) { |
|
|
|
|
|
|
|
|
|
switch ($argv[2]) { |
|
|
|
|
|
|
|
|
@ -88,11 +105,6 @@ switch ($argv[1]) {
@@ -88,11 +105,6 @@ switch ($argv[1]) {
|
|
|
|
|
|
|
|
|
|
if (empty($argv[2])) { |
|
|
|
|
|
|
|
|
|
CLI::danger(_('hostPageSnap method requires action argument')); |
|
|
|
|
CLI::break(); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($argv[2]) { |
|
|
|
|
|
|
|
|
|
case 'repair': |
|
|
|
@ -103,6 +115,10 @@ switch ($argv[1]) {
@@ -103,6 +115,10 @@ switch ($argv[1]) {
|
|
|
|
|
CLI::break(); |
|
|
|
|
exit; |
|
|
|
|
|
|
|
|
|
switch ($argv[3]) { |
|
|
|
|
|
|
|
|
|
case 'db': |
|
|
|
|
|
|
|
|
|
// Normalize & cleanup DB |
|
|
|
|
CLI::notice(_('scan database registry for missed snap files...')); |
|
|
|
|
|
|
|
|
@ -221,6 +237,9 @@ switch ($argv[1]) {
@@ -221,6 +237,9 @@ switch ($argv[1]) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case 'fs': |
|
|
|
|
|
|
|
|
|
// Cleanup FS |
|
|
|
|
CLI::notice(_('scan storage for snap files missed in the DB...')); |
|
|
|
|
|
|
|
|
@ -280,37 +299,26 @@ switch ($argv[1]) {
@@ -280,37 +299,26 @@ switch ($argv[1]) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CLI::success(_('missed snap files successfully deleted!')); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'reindex': |
|
|
|
|
|
|
|
|
|
// Optimize DB tables |
|
|
|
|
CLI::notice(_('optimize database tables...')); |
|
|
|
|
|
|
|
|
|
$db->optimize(); |
|
|
|
|
|
|
|
|
|
CLI::success(_('tables successfully optimized!')); |
|
|
|
|
//@TODO |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
CLI::danger(_('undefined action argument!')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case 'hostPage': |
|
|
|
|
|
|
|
|
|
if (empty($argv[2])) { |
|
|
|
|
|
|
|
|
|
CLI::danger(_('hostPage method requires action argument')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($argv[2]) { |
|
|
|
|
|
|
|
|
|
case 'rank': |
|
|
|
|
|
|
|
|
|
if (empty($argv[3])) { |
|
|
|
|
|
|
|
|
|
CLI::danger(_('hostPage rank requires action argument')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($argv[3]) { |
|
|
|
|
|
|
|
|
|
case 'reindex': |
|
|
|
@ -331,19 +339,9 @@ switch ($argv[1]) {
@@ -331,19 +339,9 @@ switch ($argv[1]) {
|
|
|
|
|
|
|
|
|
|
CLI::danger(_('undefined action argument')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case 'truncate': |
|
|
|
|
|
|
|
|
|
$db->truncateHostPageDom(); |
|
|
|
|
|
|
|
|
|
CLI::success(_('hostPageDom table successfully truncated')); |
|
|
|
|
exit; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
CLI::danger(_('undefined action argument')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
@ -351,9 +349,6 @@ switch ($argv[1]) {
@@ -351,9 +349,6 @@ switch ($argv[1]) {
|
|
|
|
|
|
|
|
|
|
if (empty($argv[2])) { |
|
|
|
|
|
|
|
|
|
CLI::danger(_('hostPageDom method requires action argument')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($argv[2]) { |
|
|
|
|
|
|
|
|
|
case 'generate': |
|
|
|
@ -429,13 +424,11 @@ switch ($argv[1]) {
@@ -429,13 +424,11 @@ switch ($argv[1]) {
|
|
|
|
|
exit; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
CLI::danger(_('undefined action argument')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Default message |
|
|
|
|
CLI::default('__ ______________ __'); |
|
|
|
@ -446,13 +439,29 @@ CLI::default('/_/\____/\____/\____(_)' );
@@ -446,13 +439,29 @@ CLI::default('/_/\____/\____/\____(_)' );
|
|
|
|
|
|
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default('available options:'); |
|
|
|
|
|
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default(' help - this message'); |
|
|
|
|
CLI::default(' crontab [crawl|clean] - execute crontab script queue'); |
|
|
|
|
CLI::default(' hostPage rank reindex - generate rank indexes in hostPage table'); |
|
|
|
|
CLI::default(' hostPageSnap repair - sync DB/FS relations'); |
|
|
|
|
CLI::default(' hostPageDom generate [selectors] - make hostPageDom index based on related hostPage.data field'); |
|
|
|
|
CLI::default(' hostPageDom truncate - flush hostPageDom table'); |
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default(' db '); |
|
|
|
|
CLI::default(' optimize - optimize all tables'); |
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default(' crontab '); |
|
|
|
|
CLI::default(' crawl - execute step in crawler queue'); |
|
|
|
|
CLI::default(' clean - execute step in cleaner queue'); |
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default(' hostPage '); |
|
|
|
|
CLI::default(' rank - generate hostPage.rank fields'); |
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default(' hostPageSnap '); |
|
|
|
|
CLI::default(' repair '); |
|
|
|
|
CLI::default(' db - scan database registry for new or deprecated snap files'); |
|
|
|
|
CLI::default(' fs - check all storages for snap files not registered in hostPageSnapStorage, cleanup filesystem'); |
|
|
|
|
CLI::default(' reindex - search for host pages without snap records, add found pages to the crawl queue'); |
|
|
|
|
CLI::break(); |
|
|
|
|
CLI::default(' hostPageDom '); |
|
|
|
|
CLI::default(' generate [selectors] - make hostPageDom index based on related hostPage.data field'); |
|
|
|
|
CLI::default(' truncate - flush hostPageDom table'); |
|
|
|
|
|
|
|
|
|
CLI::break(); |
|
|
|
|
|
|
|
|
|
CLI::default('get support: https://github.com/YGGverse/YGGo/issues'); |
|
|
|
|