GithubHelp home page GithubHelp logo

envoy's Introduction

Laravel Logo

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [email protected]. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.

envoy's People

Contributors

4mation avatar amayer5125 avatar arrilot avatar bakerkretzmar avatar carusogabriel avatar colorgreen avatar denlapaev avatar devajmeireles avatar driesvints avatar emanuelmutschlechner avatar finagin avatar grahamcampbell avatar jesseobrien avatar jonasemde avatar kabbouchi avatar katsuren avatar lbausch avatar mismail80 avatar nunomaduro avatar pmatseykanets avatar quynh-nguyen avatar raulduran avatar remkobrenters avatar rgant avatar simonhamp avatar snake03 avatar taylorotwell avatar themsaid avatar wells avatar whm0627 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

envoy's Issues

Suggestion: Allow a subtask to be called from a parent task.

Suggestion: Allow a subtask to be called from a parent task.

@story('s1', ['on' => ['localhost']])
    _task_s1
    common
@endstory

@task('_task_s1')
    subtask
@endtask

@task('common')
    echo "common";
@endtask

@task('subtask')
    echo "subtask called";
@endtask

This doesnt work and results in:

$ envoy run s1
[localhost]: sh: subtask: command not found
[✗] This task did not complete successfully on one of your servers.

Conditionally load variables based on command/ story name

Hi,

I would simply like a way to run variations of the @setup section based on the task type. For example if I run;
envoy run install - I can check for 'install' in the @setup section and load a set of variables, error checking and so on. This 'install' would require specific parameters.
If I run;
envoy run upgrade - I can check for the 'upgrade' command and load a separate set of setup vars, or tasks. Maybe some are shared with 'install'.
After setup, their individual stories are run.

Is this possible, can it be done easily? I've tried everything, But I cannot find a way to access these.

Thank you

Class config does not exist

  • Envoy Version: 1.5.0
  • Laravel Version: 5.8.0
  • PHP Version: 7.1.3

Description:

I'm currently trying to setup a deployment onto remote servers.It works fine but I would like going further by using Illuminate\Foundation\Application class to be able to inject some dependencies into @setup Envoy directive (e.g. retrieve some config or Eloquent models). But I keep getting this error, whatever I tried.

https://nsa40.casimages.com/img/2019/07/22/190722111809435118.png

Steps To Reproduce:

Run this script

@servers(['localhost' => '127.0.0.1'])

@include('vendor/autoload.php')

@setup
    define('LARAVEL_START', microtime(true));

    $app = require_once __DIR__.'/bootstrap/app.php';

    dump($app->make('config'));
@endsetup

@task('foo', ['on' => 'localhost'])
    ls
@endtask

Here is the file generated by Blade compiler, I don't see anything wrong on it

<?php $app = isset($app) ? $app : null; ?>
<?php $__container->servers(['localhost' => '127.0.0.1']); ?>

 <?php require_once('vendor/autoload.php'); ?>

<?php
    define('LARAVEL_START', microtime(true));

    $app = require_once __DIR__.'/bootstrap/app.php';

    dump($app->make('config'));

?>

<?php $__container->startTask('foo', ['on' => 'localhost']); ?>
    ls
<?php $__container->endTask(); ?>

Any help would be greatly appreciated, thanks!

Envoy is not working with Supervisor

  • Envoy Version: 1.5
  • Laravel Version: 5.8.*
  • PHP Version: 7.2.19-0ubuntu0.18.04.2

Envoy cant access any server trought Supervisor... I have a job that create a server in DO then use envoy to connect to it and install docker. But Envoy can't connect to the server in production... What shoul I do?

This is my Supervisor configuration:

[program:queue]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/api.posit.us/artisan queue:work
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/api.posit.us/storage/logs/queue.log

Splitting to multiple files

Not sure if possible at all currently, but the Envoy.blade.php file tends to get larger and larger when tasks are added and made more flexible.

I have already externalized most of the configuration and I was wondering if there was a possibility to split the tasks from that file and put them in another file.

If not currently possible, do you think it would technically be easy to add this? I may be able to work on a PR if that is not a huge one.

Thanks!

Include other (templated) files

While I see there is @include which calls require_once... being able to do something on the lines of (taking this from LESS)

@extend("mixins")

which includes mixins.blade.php and compiles into the main file allowing generic tasks to be shared between projects easily.

sudo support

Is there any better way to make Envoy work with sudo other than turning off password request in visudo?

Ability to specify Envoy file

Like fabric, I'd like something similar to Fabric's -f to specify a file with a non-standard name

envoy -f foo/bar.blade.php run deploy

envoy self-update returns JSON exception

Recently when running envoy self-update it returns a JSON exception related to the GitHub manifest:

Looking for updates...
[Herrera\Json\Exception\FileException]
file_get_contents(https://github.com/laravel/envoy/raw/master/envoy-manifest.json): failed to open stream: operation failed.

Envoy still works which means there's no real problem.
I've tried reinstalling the .phar but no fix.

Running Laravel Envoy version 1.0.13 on MAMP PRO PHP v5.4.25 (with the path to PHP set correctly). Have tried 5.5.10 too but same problem.

How to use @after task

I want to execute code after specyfic task execution (like e.g after task 'push' sent message to discord. I see @after is implemented but I cant figure out how to use it. I trying something like

@task( 'push', [ 'on' => 'production' ] )
    whoami
    @after
        @discord( 'https://discordapp.com/api/webhooks/63.....t', 'My message' )
    @endafter

@endtask

wish to support User-defined instruction

demo

@servers(['web' => 'localhost'])
@php
    \Blade::directive("hello", function ($message) {
        echo "echo here is message from user defined direct: $message";
    });
@endphp

@task("hello")
    @hello
@endtask

Support passing variables into Envoy tasks

I don't think envoy supports a way to pass variables into tasks. In this (simplified) example, is it possible to NOT replicate 'common' for s1 and s2?

@story('s1')
    _task_s1
    common
@endstory

@story('s2')
    _task_s2
    common
@endstory

@task('_task_s1')
    file=".env_local"
@endtask

@task('_task_s2')
    file=".env_prod"
@endtask

@task('common')
    echo "file: {{ $file }}";
    #rm -rf {{ $file }}
@endtask

The above example doesnt work and results in:

$ envoy run s1
[localhost]: file:

After update "Uncaught TypeError: Argument 1 passed to"

  • Envoy Version: 1.6.1

Description:

After the update today i am getting the following issue

$ ~/.composer/vendor/bin/envoy run deploy --commit="$CI_COMMIT_SHA"

Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Process\Process::__construct() must be of the type array, string given, called in /home/php/.composer/vendor/laravel/envoy/src/RemoteProcessor.php on line 62 and defined in /home/php/.composer/vendor/symfony/process/Process.php on line 140

TypeError: Argument 1 passed to Symfony\Component\Process\Process::__construct() must be of the type array, string given, called in /home/php/.composer/vendor/laravel/envoy/src/RemoteProcessor.php on line 62 in /home/php/.composer/vendor/symfony/process/Process.php on line 140

Server configuration parsing error

  • Envoy Version: 1.6.3
  • Laravel Version: 5.8.35
  • PHP Version: 7.1
  • Database Driver & Version: MariaDB 10.2.29

Description:

Since version 1.6.3, servers configured with a port number will be parsed incorrectly, resulting in SSH connection errors.
For example, this configuration @servers(['myserver' => 'user@server -p 2222']) will result in a "ssh: Could not resolve hostname 'user@server -p 2222'" error.
Using the same server configuration in 1.6.2 works (see this thread)

Steps To Reproduce:

add a port configuration to the server config
run

Blade comments

Blade comments {{-- Macro Task Below --}} creates the Envoy.php file but doesn't fire/execute/remove.

workaround:
// Macro Task Below //

The workaround for now is fine but figured since we are using blade why not allow the comment syntax.

Thanks,
Jose

PHP 7.1 not supported anymore

  • Envoy Version: Since 1.6.0
  • Laravel Version: 5.1
  • PHP Version: 7.0
  • Database Driver & Version: N/A

Description:

Since Envoy 1.6.0, PHP 7.0 is not supported anymore due to syntax at least in this file https://github.com/laravel/envoy/blob/v1.6.0/src/SSHConfigFile.php#L106 and it broke my build. I don't know which solution is the best, either put the supported PHP version in the composer file or use older syntax (or something else)?

I'm willing to make a PR with the solution you choose.

I've fixed the Envoy version to 1.5.0 to fix it but I was hopping that composer could handle it by itself if we set the supported PHP version in the composer file.

Steps To Reproduce:

Install the latest Envoy version and run an SSH command in a PHP 7.0 environment.

Returns to home directory on every task execution

  • Envoy Version: 1.5.0
  • Laravel Version: 5.8.18
  • PHP Version: 7.2.8
  • Database Driver & Version: Mysql 5.7.23

Description:

When executing a story directive on some remote server (CentOS 7) , each task in the story first returns to the home directory before executing the contents of the task, eg:

@story('staging', ['on' => 'staging'])
    cdSiteStaging
    git
    migrate
    composer
    npmInstallAndDev
    compileComponents
@endstory

@task('cdSiteStaging')
    cd /var/www/website/docroot
@endtask

@task('git')
    @if($branch)
        git pull origin {{ $branch }}
    @else
        git pull origin master
    @endif
@endtask

Steps To Reproduce:

Happens on a CentOS 7 server when executing the above story, eg: envoy run staging

$task variable doesn't exist in @finished section

  • Envoy Version: 1.6.1
  • Laravel Version: 6.2.0
  • PHP Version: 7.2.17

Description:

When I run a story or task the slack hooks fires a call and that all works but I only get the default message with my name and that a task has been run, but not with the name of the story or task.

I don't know if it even works for stories, but for the task it should but doesn't in my case.

Steps To Reproduce:

@servers(['live' => 'hostname'])

@task('test', ['on' => 'live'])
echo 'TEST!'
@endtask

@finished
@slack('https://hooks.slack.com/services/XXXX', '@gertjan')
@endfinished

And the end result is this:
image

Instead of Gertjanroke ran the [test] task..

Macro Empty Lines

We can't have empty lines on macro sections, it throws:

HP Notice:  Undefined index: on in phar:///usr/local/bin/envoy/src/lib/TaskContainer.php on line 225
PHP Notice:  Undefined index: as in phar:///usr/local/bin/envoy/src/lib/TaskContainer.php on line 203

remote machine pulling gitlab private repo

So normally when I do something on the remote machine, it asks me for credentials every time I try to pull... is there any way to allow this kind of behavior using envoy?

I know it must be something small, but its telling me permission denied, remote host shut down etc.

Can I catch error in console?

Hi!
Thank for your work, it's awesome!

Can you help me?

When I run envoy task, while running I have errors in console.
Can I catch console errors, and stop running envoy task?

I provide password in envoy script but it prompts to enter password manually

Hello!
With laravel 5.8 envoy command I deploy on remote server and I set password in command line, like:

envoy run Hostels2Deploy --lardeployer_password=111 --app_version=0.105a

and envoy file:

@setup
    $server_login_user= 'lardeployer';
    $lardeployer_password = isset($lardeployer_password) ? $lardeployer_password : "Not Defined";
@endsetup

@servers(['dev' => $server_login_user.':'.$lardeployer_password.'@NNN.NN.NNN.N'])


@task('clean_old_releases')
    echo "Step # 81";
    echo 'The password is: {{ $lardeployer_password }}';
    echo 'The $server_login_user is: {{ $server_login_user }}';
    echo "Step # 00 app_version ::{{ $app_version }}";

    cd {{ $release_number_dir }}
    # php artisan envoy:delete-old-versions  Hostels2Deployed
@endtask

@macro('Hostels2Deploy',['on'=>'dev'])
    clean_old_releases
@endmacro

With credentials in @servers block I expected I will not have to enter password manually, but in command line I see prompt to enter password. I output $server_login_user and $lardeployer_password vars and they have valid values.

Which is valid path ?

Escape character needed

I came out with

@servers(['web' => '192.168.1.1'])

@task('test', ['on' => 'web'])
nohup sleep 10 > /dev/null 2>&1 &
echo $!
@Endtask

when I tested it, I didn't get the pid, my workaround ends with escaping character from echo $! to echo $!

@servers(['web' => '192.168.1.1'])

@task('test', ['on' => 'web'])
nohup sleep 10 > /dev/null 2>&1 &
echo $!
@Endtask

self-update fails on PHP 5.6 Alpha2

With the new TLS/SSL settings in PHP 5.6a2, envoy is unable to perform an update due to CN problems.

file_get_contents(): Peer certificate CN=`www.github.com' did not match expected CN=`raw.github.com'
file_get_contents(): Failed to enable crypto

I got those errors while running the file_get_contents code in boris after seeing that envoy was unable to self-update.

Switching to 5.5 allows it to self-update just fine. I'm just posting this here to make you aware, I'm not sure there's anything you should / could do to address it.

Cannot use @if within @finished

  • Envoy Version: 1.5.0
  • Laravel Version: 5.8.17
  • PHP Version: 7.2.14
  • Database Driver & Version: mysql 5.7.25

Description:

The @if Blade directive cannot be used within @finished.

Steps To Reproduce:

Write the following code

@finished
    @if($env != 'local')
        @slack($slack, '#myChannel', "Deployment on {$env}: {$release} complete")
    @endif
    echo "Envoy deployment complete.\r\n";
@endfinished

results in

PHP Parse error: syntax error, unexpected '<' in /var/www/einsteinfiv2/Envoyac3a4661d761f643c317961bc4f87ff8.php on line 269

Compiled PHP file:

<?php $_vars = get_defined_vars(); $__container->finished(function() use ($_vars) { extract($_vars); 
    <?php if($env != 'local'): ?>
         if (! isset($task)) $task = null; Laravel\Envoy\Slack::make($slack, '#myChannel', "Deployment on {$env}: {$release} complete")->task($task)->send();
    <?php endif; ?>
    echo "Envoy deployment complete.\r\n";
}); ?>

I think one should be able to use Blade directive within the @finished section

Envoy no longer uses user's environment by default

  • Envoy Version: 1.5.0
  • Laravel Version: none; (I use Envoy for non-Laravel projects)

Description:

Envoy 1.5.0 no longer loads the user's environment by default. Before 1.5.0, all of a user's environment variables were available by default when running Envoy tasks.

For example, in 1.4.1, this task:

@task('test', ['on' => 'localhost'])
echo $HOME
@endtask

would produce this output:

[127.0.0.1]: /home/myusername

However, after upgrading to 1.5.0, this no longer works and $HOME is no longer defined.

I'm just using $HOME as a simple example. In my case, my deployments broke because envoy stopped using my $PATH variable, and my rsync commands that use ssh keys also stopped working (it started asking me for my key's passphrase).

Based on some quick digging, it looks like the issue might have originated with commit Add ENVOY environment var to allow checking host within tasks, on line 31 of RemoteProcessor.php.

I solved the issue for myself by rolling Envoy back to version 1.4.1.

Edit: fixed typo in code example

Ability to add a task to always run, before or after task

An example:

@before(['on' => 'dev'])
    cd /home/user/webapps/project
@endbefore

This way I wouldn't need to run cd in the beginning of each task.

I could obviously create macros, but I'd rather have this than build macros for all the simple tasks.

[Proposal] Change name of envoy file - remove .blade.php extension

First let me just say that I'm loving Envoy so far. Great little tool.

So consider this a minor nitpick, but the filename 'Envoy.blade.php' seems overly verbose to me, and also really exposes details about the file that is of no interest - I don't need to know that it is a Blade (-like) syntax file, or even that it's PHP to be honest.

Just something like calling it '.envoy' or plain 'Envoy' or similar would be simpler, and more inline with other tools like Capistrano etc.

Just a thought :-)

Semicolon in string fails to correctly parse

Problem/Motivation

I want to color the output from Envoy commands using Bash color codes. These codes contain semicolons.

The following failed to correctly parse the variable string containing a semicolon.

@setup
    $error_msg = "\033[0;31mWarning: Some message.\033[0m\n";
@endsetup

@servers(['local' => 'localhost'])

@task('test', ['on' => 'local'])
    echo {{ $error_msg }}
@endtask

The following error occurs:

[localhost]: sh: 1: 33mWarning:: not found
[✗] This task did not complete successfully on one of your servers.

To prove this is the issue, you can escape the semicolon in the variable string value to get it working:

    $error_msg = "\033[0\;31mWarning: Some message.\033[0m\n";

Proposed resolution

Given that the variable string value is wrapped in quotes, it should not be necessary to escape the semicolon within the string.

Ability to ask for more details

I was trying to make a task which would pull my app source from a GitHub repository. However, I don't want to write down my SSH pass phrase in the Envoy-file, for obvious reasons.

There should be a way for my task to ask for the pass phrase and then send it to SSH.

Using Envoy in a Laravel 5.8 app does not work

When staring an Envoy task from a Laravel 5.8 app, an exception is thrown.

 Dotenv\Dotenv::__construct() must be an instance of Dotenv\Loader, string given,

It seems caused by the fact that the compiled Envoy php file contains

(new \Dotenv\Dotenv(__DIR__, '.env'))->load();

It should be:

\Dotenv\Dotenv::create(__DIR__, '.env')->load();

Allow task servers to override story servers

Happy to take a stab at a PR here but I wanted to confirm I wasn't missing something. Consider the case where you want to update multiple staging servers, and as part of it download a production db snapshot and restore it to staging:

@servers(['staging-servers' => ['alpha.staging.example.com', 'beta.staging.example.com'], 'staging-primary' => 'alpha.staging.example.com'])

@story('stage', [ 'on' => 'staging-servers' ])
    down
    pull
    dependencies
    restoredb
    migrate
    up
@endstory

Most of these task, of course, we want to run on all servers. However, we have a "restoredb" task that grabs the latest production database backup and restores it to staging, so we can work with the latest data. We obviously only want this to run one time.

I would expect that I could override the on setting on the restoredb task specifically:

@task('restoredb', [ 'on' => 'staging-primary' ])
    ...
@endtask

But that doesn't seem to work. So first, is this expected? Second, if it is expected, is there a different way we ought go about this, and is there a downside to changing behavior so it does work this way?

Feature Request: Manageable Envoy code: Add ability for a story to call another story, or to pass variables into tasks

From all the testing I've done with Envoy over the past few months, there doesn't seem to be an efficient way to make the code DRY (as in, avoid duplication). This is more concerning than it appears because envoy scripts can get very long and complicated, even for basic deployment tasks.

Here are some real use-cases I am struggling with at the moment:
Luckily, envoy accepts passing variables into it from the command line, like so:

envoy run build --env=local
envoy run build --env=staging
envoy run build --env=production
envoy run deploy --env=staging
envoy run deploy --env=production

The first 3 build for different environments, the last 2 build and deploy to the appropriate environment.

All of these use-cases involve 90% of the same set of steps (checkout repo, pick the right env file, create build, optionally deploy to the appropriate server or keep it local), except they need to do slightly different things (like use .env.local instead of .env.production) based on the variables that are passed in.

Variables passed in from the command line can be 'read' within the @ setup directive, but the problem arises in taking it a step further from there:

  1. I don't see a way for a story to call another story dynamically, based on a parameter passed in from the command line.
  2. There's also no way that I know of to pass variables into Envoy @ tasks . I had asked for this a few months ago but it got closed . Also, asking on discord, laracasts etc did not get any answers...but I have a hard time believing that I am the only person that has this issue or use case.

I am raising this again because copy-pasting and duplicating 200 lines of a task in envoy.blade.php another 3-4 times makes zero sense to me.

The ask is simple...to provide a way to do # 1 or # 2 above, so that envoy scripts can become a lot more manageable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.