Browse Source

update cli

main
ghost 1 year ago
parent
commit
ef170f62f3
  1. 107
      cli/yggo.php

107
cli/yggo.php

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

Loading…
Cancel
Save