0

我为部署创建了一个 Envoy.blade.php 文件,但是,当我运行时envoy run deploy出现语法错误。我试图找到错误,但我没有看到它。

Envoy.blade.php

@setup
// user on web-server
$user = 'root';

$timezone = 'Europe/Moscow';

// path to the directory on web-server
$path = '/var/www/';

$current = path . '/current';

// where take your code (git clone)
$repo = 'git@github.com';

$branch = 'master';

// Directory and files with chmod 755
$chmod = [
    'storage/logs'
];

$date     = new DateTime('now', new DateTimeZone($timezone));
$release  = $path .'/release'. $date->format('YmdHis');
@endsetup

@servers(['production' => $user . '@5.453.20.189'])

@task('clone', ['on' => $on])
    mkdir -p {{ $release  }}

    git clone --depth l -b {{ $branch }} "{{ $repo }}" {{ $release }}

    echo "#1 - Repository has been cloned"
@endtask

{{-- Runs a fresh installation --}}
@task('composer', ['on' => $on])
    composer self-update

    cd {{ $release }}

    composer install --no-interaction --no-dev --prefer-dist

    echo "#2 - Composer dependencies have been installed"
@endtask

{{-- Updates composer, then runs a fresh unstallation --}}
@task('artisan', ['on' => $on])
    cd {{ $release }}

    ln -nfs {{ $path }}/.env .env;
    chfrp -h www-data .env;

    php artisan config:clear

    php artisan migrate
    php artisan clear-compiled --env-production;
    php artisan optimize --env-production;

    echo "#3 Production dependencies have been installed"
@endtask

{{-- Set permissions for various files and directories --}}
@task('chmod', ['on' => $on])

    chgrp -R www-data {{ $release }};
    chmod -R ug+rwx {{ $release }};

    @foreach($chmod as $file)
        chmod -R 775 {{ $release }}/{{ $file }}

        chown -R {{ $user }}:www-data {{ $release }}/{{ $file }}

        echo "Permissions have been set for {{ $file }}"
    @endforeach

    echo "#4 - Permissions has been set"
@endtask

@task('update_symlinks')
    ln -nfs {{ $release }} {{ $current }};
    chgrp -h www-data {{ $current }};

    echo "#5 - Symlinks has beeb set"
@endtask

{{-- Run all deployment task --}}
@macro('deploy', ['on', => 'production'])
    clone
    composer
    artisan
    chmod
    update_symlinks
@endmacro

运行命令后,我在第 79 行收到错误envoy run deploy。请帮我找出错误。

4

1 回答 1

0

这里有几个问题,它们列在上面的评论中。试试下面的。

@setup
    $user = 'root';
    $timezone = 'Europe/Moscow';
    $path = '/var/www/';
    $current = $path . '/current';
    $repo = 'git@github.com';
    $branch = 'master';

    $chmod = [
        'storage/logs'
    ];

    $date = new DateTime('now', new DateTimeZone($timezone));
    $release = $path .'/release'. $date->format('YmdHis');
@endsetup

@servers(['production' => $user . '@5.453.20.189'])

{{-- Run all deployment tasks --}}
@macro('deploy', ['on' => 'production'])
    clone
    composer
    artisan
    chmod
    update_symlinks
@endmacro

@task('clone', ['on' => $on])
    mkdir -p {{ $release  }}
    git clone --depth l -b {{ $branch }} "{{ $repo }}" {{ $release }}
    echo "#1 - Repository has been cloned"
@endtask

{{-- Runs a fresh installation --}}
@task('composer', ['on' => $on])
    composer self-update
    cd {{ $release }}
    composer install --no-interaction --no-dev --prefer-dist
    echo "#2 - Composer dependencies have been installed"
@endtask

{{-- Updates composer, then runs a fresh unstallation --}}
@task('artisan', ['on' => $on])
    cd {{ $release }}
    ln -nfs {{ $path }}/.env .env;
    chfrp -h www-data .env;
    php artisan config:clear
    php artisan migrate
    php artisan clear-compiled --env-production;
    php artisan optimize --env-production;
    echo "#3 Production dependencies have been installed"
@endtask

{{-- Set permissions for various files and directories --}}
@task('chmod', ['on' => $on])
    chgrp -R www-data {{ $release }};
    chmod -R ug+rwx {{ $release }};
    @foreach($chmod as $file)
        chmod -R 775 {{ $release }}/{{ $file }}
        chown -R {{ $user }}:www-data {{ $release }}/{{ $file }}
        echo "Permissions have been set for {{ $file }}"
    @endforeach
    echo "#4 - Permissions has been set"
@endtask

@task('update_symlinks')
    ln -nfs {{ $release }} {{ $current }};
    chgrp -h www-data {{ $current }};
    echo "#5 - Symlinks has beeb set"
@endtask
于 2019-07-02T06:18:43.170 回答