First program to open cowboy

Source: Internet
Author: User

Start:

Erlang is not only a language, but also an operating system for your application. Erlang developers rarely writes standalone modules, which writes libraries or applications, and then calls these organizations together as a release. A release contains all the applications that the Erlang VM plus needs to run, so he can push directly to production. (That is, you typically use Erlang to write libraries and applications, and then package the libraries and applications together and publish them, and this release contains everything you need)

This chapter guides you through all of the Cowboy Set the steps to write your first application and generate your first release. the end of this chapter you should know all: you need to push your first Cowboy application Generation.

Boot program:

we are ready to use erlang.mk creating the system, it also provides a bootstrap feature that allows us to start quickly without having to deal with small details.

First, create a path for our reference.

then we need to download Erlang.mk, use the command or download it manually.

wget https://raw.githubusercontent.com/ninenines/erlang.mk/master/erlang.mk

If you encounter an inability to establish SSL The connection problem can be using the following command:

wget--no-check-certificate https://raw.githubusercontent.com/ninenines/erlang.mk/master/erlang.mk

we can now guide our application. Because we are ready to produce a release, and we can guide it.

Make-f Erlang.mk Bootstrap Bootstrap-rel

This command produces a Makefile, a basic application, and Create the version of the publication file that you want. We can already create and launch this release. As shown below:

$ make...$./_rel/hello_erlang_release/bin/hello_erlang_release console ... ([email protected]) 1>

input Command I () to view the running process, including a Hello_erlang_sup the process. This Supervisor is our application.

this Release at present nothing is done, the remainder of this chapter we will add Cowboy as a dependent and write a simple "Hello World" processing.

Cowboy Settings:

Add Cowboy as a dependency to your application, you need to modify two files: MakeFile and application resource files.

Modify Makefile allows the creation of systems to know what it needs Fetch and Compiling Cowboy, To do this, we need to simply add a line to the Makefile file, as shown below:

Modify the application resource file,src/hello_erlang.app.src, allow to create the system to know that he needs to include cowboy in release and automatically start it. This is a different step because some dependencies are required in the development environment.

we simply add Cowboy to the Applications list, in Stdlib to the right, do not forget the comma delimiter.

you may want a description of the application when you write the file. Add descriptive information after the description.

If you run now Make and Open Release , Cowboy will be included and automatically turned on. However, these are not enough, because cowboy does nothing by default, we still need to tell Cowboy to listen to the connection.





First program to open cowboy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.