我有一个带有此“命令”的TYPO3-Project的部署脚本:
within('{{release_path}}', function () {
run('{{php}} ./vendor/bin/typo3cms install:generatepackagestates --activate-default' );
});
我与./vendor/bin/dep deploy -vvv --install dev
一起部署。
问题部署部分的输出为:
> cd /var/www/html/deployer/releases/20180620081909 && php ./vendor/bin/typo3cms install:generatepackagestates --activate-default
< The following extensions have been added to the generated PackageStates.php file: core, extbase, fluid, install, frontend, fluid_styled_content, info, info_pagetsconfig, extensionmanager, lang, setup, rte_ckeditor, rsaauth, saltedpasswords, func, wizard_crpages, wizard_sortpages, about, backend, belog, beuser, context_help, cshmanual, documentation, felogin, filelist, form, impexp, lowlevel, recordlist, reports, scheduler, sv, sys_note, t3editor, tstemplate, viewpage, bra_projectfiles_mrt, bra_system, extension_builder, mask, news, realurl, t3adminer, typoscript_rendering, vhs
但是在我的... / deployer / shared / web / typo3conf /中,没有生成PackageStates.php。
并且,如果我手动执行,则效果很好:
[www-data@xyz ~/html/deployer/releases/20180620081909 ] $ php ./vendor/bin/typo3cms install:generatepackagestates --activate-default
The following extensions have been added to the generated PackageStates.php file: core, extbase, fluid, install, frontend, fluid_styled_content, info, info_pagetsconfig, extensionmanager, lang, setup, rte_ckeditor, rsaauth, saltedpasswords, func, wizard_crpages, wizard_sortpages, about, backend, belog, beuser, context_help, cshmanual, documentation, felogin, filelist, form, impexp, lowlevel, recordlist, reports, scheduler, sv, sys_note, t3editor, tstemplate, viewpage, bra_projectfiles_mrt, bra_system, extension_builder, mask, news, realurl, t3adminer, typoscript_rendering, vhs
[www-data@xyz ~/html/deployer/releases/20180620081909 ]
$ ls ~/html/deployer/shared/web/typo3conf/
LocalConfiguration.php PackageStates.php l10n
我想用Deploy-Script而不是手工生成此PackageStates.php。
我该怎么做?
Edit1:不带登录信息的deploy.php
<?php
require_once 'vendor/brandung/deployer/recipes/typo3.php';
/**
* Shared directories
*/
set('shared_dirs', [
'{{typo3_webroot}}/fileadmin',
'{{typo3_webroot}}/typo3temp',
'{{typo3_webroot}}/uploads',
'{{typo3_webroot}}/typo3conf/l10n',
]);
// Initial upload for composer install process
set('uploadFiles', ['composer_montea.json' => 'composer.json']);
env('composerServer', ['SECRET']);
env('composerUser', ['SECRET']);
env('composerPassword',['SECRET']);
task('deploy:update_code', function () {
foreach (get('uploadFiles') as $file=>$targetFile) {
upload($file,'{{release_path}}/'.$targetFile);
}
});
task('deploy:update_code_live', function () {
set('uploadFiles', ['composer_montea_live.json' => 'composer.json']);
foreach (get('uploadFiles') as $file=>$targetFile) {
upload($file,'{{release_path}}/'.$targetFile);
}
})->onlyOn(['live']);
task('deploy:update_code_stage', function () {
set('uploadFiles', ['composer_montea_stage.json' => 'composer.json']);
foreach (get('uploadFiles') as $file=>$targetFile) {
upload($file,'{{release_path}}/'.$targetFile);
}
})->onlyOn(['stage']);
task('typo3:realurl_config',function() {
within('{{release_path}}', function () {
run('ln -nfs ext/bra_projectfiles_mrt/Configuration/Plugin/realurl/realurl_conf.php {{typo3_webroot}}/typo3conf/realurl_conf.php' );
});
});
task('typo3:packagestates_fix',function() {
within('{{release_path}}', function () {
run("ln -nfs ../../../../shared/{{typo3_webroot}}/typo3conf/PackageStates.php {{typo3_webroot}}/typo3conf/PackageStates.php");
});
});
task('typo3:mask_symlink',function() {
within('{{release_path}}', function () {
run('ln -nfs ext/bra_projectfiles_mrt/mask.json {{typo3_webroot}}/typo3conf/mask.json' );
});
});
task('deploy:install_typo3', function () {
// Continue if --install option is set
if (!input()->getOption('install')) {
return;
}
// Create the database
run('mysql -h{{dbHost}} -u{{dbUser}} -p\'{{dbPassword}}\' -P{{dbPort}} -e "CREATE DATABASE IF NOT EXISTS {{dbName}};"');
run('mysql -h{{dbHost}} -u{{dbUser}} -p\'{{dbPassword}}\' -P{{dbPort}} -Nse "show tables" {{dbName}} | while read table; do mysql -h{{dbHost}} -u{{dbUser}} -p\'{{dbPassword}}\' -P{{dbPort}} -e "drop table $table" {{dbName}}; done');
// Install TYPO3 via cli
run('cd {{release_path}} && {{bin/php_cli}} ./vendor/bin/typo3cms install:setup --non-interactive --use-existing-database ' .
' --database-host-name="{{dbHost}}"' .
' --database-port="{{dbPort}}"' .
' --database-user-name="{{dbUser}}"' .
' --database-user-password="{{dbPassword}}"' .
' --database-name="{{dbName}}"' .
' --admin-user-name="{{typo3AdminUser}}"' .
' --admin-password="{{typo3AdminPassword}}"' .
' --site-name="{{typo3Sitename}}"' .
' --site-setup-type="site"');
within('{{release_path}}', function () {
run('{{php}} ./vendor/bin/typo3cms install:generatepackagestates --activate-default' );
});
// Sets up all extensions that are marked as active in the system.
within('{{release_path}}', function () {
run('{{php}} ./vendor/bin/typo3cms extension:setupactive' );
});
within('{{release_path}}', function () {
run("cp {{typo3_webroot}}/typo3conf/LocalConfiguration.php {{sharedPath}}/{{typo3_webroot}}/typo3conf/LocalConfiguration.php");
});
set('installDone', true);
// Install / activate Extensions via cli
// Deprecated
/*$cmd = 'ls {{release_path}}/web/typo3conf/ext/;';
$extensionDir = explode(PHP_EOL, (string)run($cmd)->getOutput());
foreach ($extensionDir as $extension) {
if (trim($extension)) {
$cmd = 'cd {{release_path}} && {{bin/php_cli}} ./vendor/bin/typo3cms extension:activate ' . $extension;
run($cmd);
}
}*/
});
task('frontend:grunt',function() {
within('{{release_path}}', function () {
run("cd {{release_path}}/web/typo3conf/ext/bra_projectfiles_mrt/capitan && ln -nfs {{deploy_path}}/shared/web/typo3conf/ext/bra_projectfiles_mrt/capitan/node_modules node_modules");
});
within('{{release_path}}', function () {
run("cd {{release_path}}/web/typo3conf/ext/bra_projectfiles_mrt/capitan && {{grunt}} project:finish");
});
});
task('typo3:modifyIndexCopy',function() {
within('{{release_path}}', function () {
run("cd {{release_path}}/web/ && rm -f index.php && cp ../vendor/typo3/cms/index.php index.php");
});
})->onlyForStage(['staging','live']);
task('typo3:form_yaml_path_fix',function() {
within('{{release_path}}', function () {
run("cd {{release_path}}/web/typo3conf/ext/bra_projectfiles_mrt/Resources/Private/Plugins/form/Yaml && ln -nfs {{deploy_path}}/shared/web/typo3conf/ext/bra_projectfiles_mrt/Resources/Private/Plugins/form/Yaml/Configurations Configurations");
});
});
task('typo3:backend_protection', function () {
upload('.htaccess','{{release_path}}/vendor/typo3/cms/typo3/.htaccess');
upload('.htpasswd','{{release_path}}/vendor/typo3/cms/typo3/.htpasswd');
})->onlyOn(['live']);
before('deploy:shared', 'deploy:update_code_live');
before('deploy:shared', 'deploy:update_code_stage');
after('mysql:import','typo3:realurl_config');
after('typo3:realurl_config','typo3:packagestates_fix');
after('typo3:packagestates_fix','typo3:mask_symlink');
#after('typo3:packagestates_fix','typo3:form_yaml_path_fix');
#after('typo3:mask_symlink','frontend:grunt');
after('frontend:grunt','typo3:modifyIndexCopy');
//after('typo3:mask_symlink', 'typo3:backend_protection');
答案 0 :(得分:1)
我找到了解决方案:
我在set('installDone', true);
之前添加了以下行
// Copy LocalConfiguration.php and PackageStates.php to shared folder
within('{{release_path}}', function () {
run("cp {{typo3_webroot}}/typo3conf/LocalConfiguration.php {{sharedPath}}/{{typo3_webroot}}/typo3conf/LocalConfiguration.php");
run("cp {{typo3_webroot}}/typo3conf/PackageStates.php {{sharedPath}}/{{typo3_webroot}}/typo3conf/PackageStates.php");
});
第二个复制命令是缺少的部分。
答案 1 :(得分:0)
经过深入挖掘,我能够找到问题的原因。
如果从当前目录调用Deployer,它将使用Composer的自动加载功能,并且包括// Custom exception that wraps existing Result
case class MyCustomException(result: Result) extends Exception
class ModuleDao {
...
def getHandbooks(offset, limit): Future[List[Module] = {
// You'd probably want to do this asynchronously
// But for demonstration purposes
val origRetVal: Either[Result, List[Module] = ??? // current code returning your Either
origRetVal match {
case Right(modules: List[Module]) =>
Future.successful(modules)
case Left(result: Result) =>
// Failed future wrapping custom exception
Future.failed(MyCustomException(result))
}
}
...
}
。在此文件中,导出了各种内部环境变量,例如df.sum().sort_values(ascending=False).plot.bar(figsize = (10,5))
,TYPO3使用这些变量来设置其路径。
这些环境变量中的路径与您当前的工作目录匹配,并且与vendor/typo3/autoload-include.php
中的路径完全不同。这样TYPO3_PATH_ROOT
将在您当前的工作目录中生成{{release_path}}
。
现在可以尝试手动修复这些问题,但实际上这不是必需的,因为在install:generatepackagestates
中运行PackageStates.php
时还包括{{release_path}}/vendor/typo3/autoload-include.php
。只是该文件不执行任何操作,因为它不会覆盖现有的环境变量。
因此,您可以将其添加到composer install
:
{{release_path}}
我建议添加一个单独的任务,该任务在使用以下自定义项之前显式运行deploy.php
:
add('env', [
'TYPO3_PATH_APP' => '',
'TYPO3_PATH_COMPOSER_ROOT' => '',
'TYPO3_PATH_ROOT' => '',
'TYPO3_PATH_WEB' => '',
]);