Meet Envoyer.io (part 2)

Original author: Matt Stauffer
  • Transfer
Envoyer is a new service from Taylor Otwell, creator of Laravel. Already now you can watch a series of screencasts on Laracasts about this service. This is the second and last part of the description of this service.

Meet Envoyer.io (Part 1)

This section will describe the more advanced features of Envoyer.

image



Customization of deploy hooks


Envoyer has 4 steps in the deployment process, and you, in turn, can execute any of your scripts before and after any of these steps. These steps are: Clone a new release , Install composer dependencies , Activate a new release, and Remove old releases .
image

Near each step there is a “gear” button, clicking on it brings you to the next screen:
image

There you can add hooks before and after the selected step. Click on Add Hook in the part you need.
image

As you can see, for each hook you can specify your name, specify the user under which you want to execute the script, and the body of the hook, which has access to the variable{{release}}, which stores the path in the folder of the latest release (for example, /home/my-user/website.com/releases/20150316083301).
Note that you can also use drag & drop to change the execution order of hooks.
image

Cancellations


But what if you performed a new deployment and realized that you had broken everything? Normally, you would have to connect to the server via ssh, git log, looking to the right you commit to copy the hash of a commit git checkout THAT_HASH, composer installand only then, perhaps, would have calmed down for a few minutes.

Using Envoyer, your previous release will be operational in the folder releases. Just go to the dashboard of your project, find the deploy that deployed the working code and click the “Redeploy” button. A symbolic link currentwill simply point to the working folder in the folder releasesand it will work again.
image

Health


You might notice the Post-Deployment Health section on the project dashboard. There are icons for New York, London and Singapore - three regions from which Envoyer checks the availability of your application. Until you enter the Health Check URL, these icons will be question marks.
image

Each project can have a Health Check URL that will be called by Envoyer after each deployment. You can edit this URL in the project settings.
image

After the deployment, Envoyer looks at the HTTP response from the specified URL, and check if the response code is 200(OK). If so, then Envoyer considers the app “healthy.” You can specify the home page of your site or make a special test URL that can fully indicate whether your server is “healthy”.
If all is well, then you will see green checkmarks.
image

If something breaks, you will see red crosses (and then you most likely will need the “Cancellations” section):
image

Deploy to multiple servers


If you want to deploy to several servers at once, just add them to the project and the server will automatically participate in the deployment.

Deployment stages

Note that when the deployment process is in progress, until the previous deployment step on each server is completed, further steps are not started, which allows the servers to remain fully synchronized with each other.
image

Synchronization of environment settings

If you have a local configuration file that you want to synchronize with the servers ( .envin Laravel 5, .env.phpin Laravel 4), click the Manage Environment button in the project dashboard.

Note that the file is encrypted with a password that is not stored in Envoyer, so do not lose the “Environment Key”.
image

As soon as you enter the password, you will be given a text field, which is essentially a code editor. Write what you need in this field, and the contents will be saved to a file ( .envif you selected the project type Laravel 5 or Other, and .env.phpif the project type - Laravel 4).
image

Now select the servers you want to save it to and save.
Envoyer will save this file to the root of the project on the servers and create all the necessary symbolic links.

Notifications


In the “Notifications” tab, you can configure Envoyer to notify you of important events. Envoyer can currently notify in Hipchat and Slack.
image
image

Heartbeats


One of the biggest challenges in managing server health is ensuring that all cron tasks always work. Envoyer Heartbeats allows you to set the condition that if the specified URL responds with the specified frequency, then cron work is "alive". If there is no ping, Envoyer will notify you of this.
To add a Heartbeat, in the Heartbeats tab, click on the Add Heartbeat button .
image

You can specify a name and specify the frequency with which it is expected to receive ping from a cron task.
image
Once you add it, the status will be Healthy. Until the specified time has passed, the status will remain Healthy. That is, if you select 10 minutes, it will remain Healthy for 10 minutes after creation.

Ping heartbeat

Each Heartbeat has its own unique URL, which can be obtained on the Heartbeats tab. It will be in the following format: beats.envoyer.io/heartbeat/203849102395790125
In a regular cron file, you can do this as follows to ping a Heartbeat:
php yourfile.php && curl https://beats.envoyer.io/heartbeat/203849102395790125


If you use Laravel, in the latest version a method has been added to the scheduler thenPing()that allows you to ping any URL after completing the cron task. This is perfect for Heartbeats:
image

This is what the notification looks like if there is no ping:
image

Teamwork


Envoyer allows an unlimited number of people to access your servers. If someone in your team wants to work with you on the deployment of servers, but does not want to create your account with the details of the payment card, you can create an account by selecting “I'm just collaborating with others.” when registering.
image

Each project has a Collaborators tab where you can add people by indicating their email.
image

Note that these people will have access to all functions except deleting the project.

FAQ



Will Envoyer be a replacement forge?

Not. Envoyer does not manage servers. But he will make a great pair of Forge.

How does Envoyer log in to the server?

After adding a new server, Envoyer will give you the SSH key that you need to add to the file of the authorized_keysdesired user

Can I use Envoyer with a non-Laravel project?

Oh sure. True, some automatic settings will not work. For example, the automatic creation of symbolic links to a folder storage. But this can be achieved using hooks.

If I use Forge, do I need to connect the site to the Git repository in Forge?

No, just launch the site without connecting to any repository. Envoyer will do the rest.

What happens if an error occurs in any deployment step?

Envoyer will notice this and notify you about it. Deploy will be canceled.
image

Also popular now: