feat: единая админка runtime-конфигов и indpic (#22)
deploy-preland / deploy zoomstage.online (push) Successful in 1m1s
deploy-preland / deploy zoomstage.online (push) Successful in 1m1s
This commit is contained in:
1 parent
5b6b2d2053
commit
9515c1c62b
52 files changed
+2459
-34
No files matched your search
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
// Пароль читается только из stdin; не передавать его через аргументы командной строки.
|
||||
$password=rtrim(stream_get_contents(STDIN),"\r\n");if(strlen($password)<12){fwrite(STDERR,"Пароль должен содержать не менее 12 символов.\n");exit(1);}echo password_hash($password,PASSWORD_DEFAULT)."\n";
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require dirname(__DIR__).'/bootstrap.php';
|
||||
// Начальная настройка из закрытого stdin. Секреты никогда не выводятся.
|
||||
try{$input=json_decode(stream_get_contents(STDIN),true,64,JSON_THROW_ON_ERROR);$store=new PrelandAdmin\Store();foreach($input as $item){$secret=$item['secret']??null;unset($item['secret']);$target=$store->saveTarget($item,$secret);$actual=$store->target($target['id']);(new PrelandAdmin\Transport($store,$actual))->test();$store->verifyTarget($target['id'],$actual);}echo "Подключения импортированы и проверены.\n";}catch(Throwable){fwrite(STDERR,"Импорт не выполнен. Проверьте приватные параметры и соединения.\n");exit(1);}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
$jobIndex=array_search('--job',$argv,true);
|
||||
// Supervisor не создаёт Imagick: его policy time не должна накапливаться между заданиями.
|
||||
if($jobIndex===false)define('PRELAND_ADMIN_SUPERVISOR',true);
|
||||
require dirname(__DIR__).'/bootstrap.php';
|
||||
$store=new PrelandAdmin\Store();$jobs=new PrelandAdmin\Jobs($store);
|
||||
if($jobIndex!==false){$id=$argv[$jobIndex+1]??'';if(!preg_match('/^[a-f0-9]{32}$/D',$id))exit(2);$jobs->run($id);exit(0);}
|
||||
$once=in_array('--once',$argv,true);
|
||||
do {
|
||||
try {
|
||||
$id=$jobs->pending();
|
||||
if($id!==null){
|
||||
$process=proc_open([PHP_BINARY,__FILE__,'--job',$id],[0=>['pipe','r'],1=>STDOUT,2=>STDERR],$pipes);
|
||||
if(!is_resource($process))throw new RuntimeException('Не удалось запустить исполнитель.');fclose($pipes[0]);
|
||||
$deadline=microtime(true)+max(30,min(900,(int)(getenv('ADMIN_JOB_TIMEOUT')?:300)));$exit=null;
|
||||
do{$state=proc_get_status($process);if(!$state['running']){$exit=$state['exitcode'];break;}if(microtime(true)>$deadline){proc_terminate($process);usleep(250000);$state=proc_get_status($process);if($state['running'])proc_terminate($process,9);$exit=124;break;}usleep(100000);}while(true);
|
||||
$closed=proc_close($process);if(($exit??$closed)!==0)$jobs->interrupted($id);
|
||||
}
|
||||
}catch(Throwable){fwrite(STDERR,"Не удалось обработать очередь. Повтор через 2 секунды.\n");}
|
||||
if(!$once)sleep(2);
|
||||
}while(!$once);
|
||||
Reference in new issue
Block a user