separate main rebuilder from bootstrap environment
This commit is contained in:
parent
4379d3f428
commit
be2354c9b8
27
build-worker
Executable file
27
build-worker
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/lib/bootstrap.php';
|
||||
|
||||
function main($args) {
|
||||
$config = setup_vars();
|
||||
|
||||
$total = $args[0];
|
||||
$pos = $args[1];
|
||||
|
||||
// Perform build tasks
|
||||
|
||||
if ($pos == 0) {
|
||||
buildcommon();
|
||||
if (array_key_exists('redirect', $config)) {
|
||||
buildredirects( $config['redirect'] );
|
||||
}
|
||||
if (array_key_exists('golang-subpackages', $config)) {
|
||||
buildgosubpackages( $config['golang-subpackages'] );
|
||||
}
|
||||
} else {
|
||||
buildprojects($pos, array_decimate(listprojects(), $total, $pos));
|
||||
}
|
||||
}
|
||||
|
||||
main(array_slice($_SERVER['argv'], 1));
|
@ -1,4 +1,3 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 'On');
|
||||
@ -11,12 +10,17 @@ require __DIR__.'/CProject.php';
|
||||
|
||||
define('SHIELDS_CACHE_DIR', __DIR__.'/../shields_cache/');
|
||||
|
||||
function main($args) {
|
||||
$basedir = './';
|
||||
$total = $args[0];
|
||||
$pos = $args[1];
|
||||
/**
|
||||
* Set up global defines for a given codesite project
|
||||
* Should be called once we have the root path for a codesite project.
|
||||
*
|
||||
*/
|
||||
function setup_vars(string $basedir="./"): array {
|
||||
|
||||
// Parse configuration
|
||||
if (! is_file($basedir.'config.ini')) {
|
||||
die("[FATAL] Non-file '${basedir}config.ini'!\n");
|
||||
}
|
||||
|
||||
$config = @parse_ini_file(
|
||||
$basedir . 'config.ini',
|
||||
@ -25,7 +29,7 @@ function main($args) {
|
||||
);
|
||||
|
||||
if ($config === false) {
|
||||
die("[FATAL] Couldn't load '${basedir}/config.ini'!\n");
|
||||
die("[FATAL] Couldn't load '${basedir}config.ini'!\n");
|
||||
}
|
||||
|
||||
define('BASEDIR', $basedir);
|
||||
@ -39,19 +43,5 @@ function main($args) {
|
||||
define('ARTICLE_HEADER', (isset($config['codesite']['article_header']) ? $config['codesite']['article_header'] : 'ABOUT') );
|
||||
define('SHIELDS_PREFIX', isset($config['codesite']['shields_prefix']));
|
||||
|
||||
// Perform build tasks
|
||||
|
||||
if ($pos == 0) {
|
||||
buildcommon();
|
||||
if (array_key_exists('redirect', $config)) {
|
||||
buildredirects( $config['redirect'] );
|
||||
}
|
||||
if (array_key_exists('golang-subpackages', $config)) {
|
||||
buildgosubpackages( $config['golang-subpackages'] );
|
||||
}
|
||||
} else {
|
||||
buildprojects($pos, array_decimate(listprojects(), $total, $pos));
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
main(array_slice($_SERVER['argv'], 1));
|
||||
|
@ -40,7 +40,7 @@ buildsite() {
|
||||
|
||||
local threadcount=$(numcpus)
|
||||
for i in $(seq 0 "$threadcount") ; do
|
||||
"${APP_DIR}/lib/bootstrap.php" "$threadcount" "$i" &
|
||||
"${APP_DIR}/build-worker" "$threadcount" "$i" &
|
||||
done
|
||||
wait
|
||||
|
||||
|
Reference in New Issue
Block a user