在laravel 5.8中,我运行envoy命令,并且应该将新发行版上载到新的子目录中,并且在克隆项目并安装composer之后 .env文件将被复制到项目中。 但是在运行命令时,由于找不到.env,我在引用db时遇到错误:
$ envoy run VotesDeploy
lardeployer@NNN.NN.NNN.N's password:
[lardeployer@NNN.NN.NNN.N]: $release_number :: /var/www/html/VotesDeployed/release/20190329095641
[lardeployer@NNN.NN.NNN.N]: $database_factories_path :: /var/www/html/VotesDeployed/release/20190329095641/database/factories
[lardeployer@NNN.NN.NNN.N]: $git_clone_command git clone --depth 1 -b master "git@bitbucket.org:myaccount/votes.git" "/var/www/html/VotesDeployed/release/20190329095641"::
[lardeployer@NNN.NN.NNN.N]: Cloning into '/var/www/html/VotesDeployed/release/20190329095641'...
[lardeployer@NNN.NN.NNN.N]: Checking out files: 13% (198/1468)
...
[lardeployer@NNN.NN.NNN.N]: Checking out files: 100% (1468/1468)
[lardeployer@NNN.NN.NNN.N]: Checking out files: 100% (1468/1468), done.
[lardeployer@NNN.NN.NNN.N]: Step # 1 : Repository has been cloned
lardeployer@NNN.NN.NNN.N's password:
[lardeployer@NNN.NN.NNN.N]: Step # 2 start : composer_installing dependencies installing
[lardeployer@NNN.NN.NNN.N]: Loading composer repositories with package information
[lardeployer@NNN.NN.NNN.N]: Updating dependencies
[lardeployer@NNN.NN.NNN.N]: Package operations: 124 installs, 0 updates, 0 removals
...
[lardeployer@NNN.NN.NNN.N]: Loading from cache
[lardeployer@NNN.NN.NNN.N]: - Installing ratchet/rfc6455 (0.2.4):
[lardeployer@NNN.NN.NNN.N]: Loading from cache
[lardeployer@NNN.NN.NNN.N]: - Installing cboden/ratchet (v0.4.1):
[lardeployer@NNN.NN.NNN.N]: Loading from cache
[lardeployer@NNN.NN.NNN.N]: - Installing beyondcode/laravel-websockets (1.1.1):
[lardeployer@NNN.NN.NNN.N]: Loading from cache
[lardeployer@NNN.NN.NNN.N]: Writing lock file
[lardeployer@NNN.NN.NNN.N]: Generating optimized autoload files
[lardeployer@NNN.NN.NNN.N]: > Illuminate\Foundation\ComposerScripts::postAutoloadDump
[lardeployer@NNN.NN.NNN.N]: > @php artisan package:discover
[lardeployer@NNN.NN.NNN.N]: In Connection.php line 664:
[lardeployer@NNN.NN.NNN.N]: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using pa
[lardeployer@NNN.NN.NNN.N]: ssword: NO) (SQL: select * from information_schema.tables where table_schem
[lardeployer@NNN.NN.NNN.N]: a = forge and table_name = vt2_settings)
[lardeployer@NNN.NN.NNN.N]: In PDOConnection.php line 31:
[lardeployer@NNN.NN.NNN.N]: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using pa
[lardeployer@NNN.NN.NNN.N]: ssword: NO)
[lardeployer@NNN.NN.NNN.N]: In PDOConnection.php line 27:
[lardeployer@NNN.NN.NNN.N]: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using pa
[lardeployer@NNN.NN.NNN.N]: ssword: NO)
[lardeployer@NNN.NN.NNN.N]: Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
[✗] This task did not complete successfully on one of your servers.
我的/_wwwroot/lar/DeploymentApps/votes/Envoy.blade.php:
@setup
// Under directory /mnt/_work_sdb8/wwwroot/lar/DeploymentApps/votes RUN
// export PATH="$PATH:~/.composer/vendor/bin"
// envoy run VotesDeploy
$server_login_user= 'lardeployer';
$timezone= 'Europe/Kiev';
$path= '/var/www/html/VotesDeployed';
$current = $path . '/current';
// git clone git@bitbucket.org:myaccount/votes.git
$repo= 'git@bitbucket.org:myaccount/votes.git';
$branch= 'master';
// Directory and files with chmod 755
$writableDirs= [
'/storage/logs',
'/bootstrap/cache'
];
$now_date = new DateTime('now', new DateTimeZone($timezone));
$release_number = $path . '/release/' . $now_date->format('YmdHis');
$git_clone_command = 'git clone --depth 1 -b '.$branch.' "'.$repo.'" '.' "'.$release_number.'"';
$database_factories_path= $release_number.'/database/factories';
@endsetup
@servers(['production' => $server_login_user.'@NNN.NN.NNN.N'])
@task( 'clone_project', ['on'=>$on] )
echo '$release_number :: {{ $release_number }}';
echo '$database_factories_path :: {{ $database_factories_path }}';
echo '$git_clone_command {{ $git_clone_command }}::';
mkdir -p {{$release_number}}
{{ $git_clone_command }}
mkdir -p {{$database_factories_path}}
echo "Step # 1 : Repository has been cloned";
@endtask
@task( 'composer_installing', ['on'=>$on] )
cd {{ $release_number }}
echo "Step # 2 start : composer_installing dependencies installing";
composer install --no-interaction --no-dev --prefer-dist
echo "Step # 2 : composer_installing dependencies has been installed";
@endtask
@task( 'artisan_running', ['on'=>$on] )
cd {{ $release_number }}
ln -nfs {{ $path }}/.env .env
chgrp -h www.data .env
php artisan config:clear
php artisan migrate
php artisan clear-compiled -- env=production
php artisan optimize --env=production
echo "Step # 3 : Production dependencies has been installed";
@endtask
@task( 'chmod_settings', ['on'=>$on] )
chgrp -R www-data {{ $release_number }}
chmod -R ug-rwx {{ $release_number }}
echo "Step # 4 : chmod_settings = Permissions setting";
@foreach($writableDirs as $file)
chmod -R 775 {{ $release_number }}/{{ $file }}
chown -R {{ $server_login_user }}:www-data {{ $release_number }}/{{ $file }}
echo "Permisions has been for file {{ $file }}";
@endforeach
echo "Step # 4 : chmod_settings = Permissions has been set";
@endtask
@task( 'update_symlinks' )
ln -nfs {{ $release_number }} {{ $current }};
chgrp -h www-data {{ $current }};
echo "Step # 5 : Symlink has been set";
@endtask
@macro('VotesDeploy',['on'=>'production'])
clone_project
composer_installing
artisan_running
chmod_settings
update_symlinks
@endmacro
为什么在composer_installing阶段引用db。 错误消息是:
select * from information_schema.tables where table_schema = forge and table_name = vt2_settings
vt2_settings是我的表,但是我仅在控件中使用它。为什么我在错误描述中看到Illuminate \ Foundation \ ComposerScripts :: postAutoloadDump引用它?
有什么解决办法吗?
谢谢!