duanhan5388 2019-02-25 10:35
浏览 67

使用Laravel Envoy进行部署时出现语法错误

I created an Envoy.blade.php file for deployment, however, when I run envoy run deploy I get a syntax error. I tried to find the error but I don't see it.

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

I get the error on line 79 after I run the command envoy run deploy. Please, help me find the error.

  • 写回答

1条回答 默认 最新

  • dsi37923 2019-07-02 06:18
    关注

    There's a couple of issues here and they are listed in the comments above. Try the following.

    @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
    
    评论

报告相同问题?

悬赏问题

  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面