![]() We can easily view our applications running as a unit, or as a whole with tools like observer: Why it matters: monitoring and introspectionīy relying on applications, you gain supervision, fault tolerance, and introspection into your running system. Those are 74 snippets of code (Ruby blocks) spread around multiple files in a non-specified order! Having control of the initialization logic is extremely important to know exactly what your app is running and to keep boot times fast. Loading development environment (Rails 4.2.2) This is a stark contrast to Rails initialization which is extremely complex and requires extensions to hijack a single, sequential initialization flow. The consequence is that it doesn’t matter if you are using Phoenix or not, every application has its own and contained start/stop mechanism. The start/2 function must return the identifier of a supervised process, such as _link aboveĪ similar flow happens when stopping your application.Every application has a specification, that may specify which module to invoke when the application will be initialized:ĭefmodule Phoenix do def start ( _type, _args ) do.The trail usually goes like this (using Phoenix itself as an example): Why it matters: startup and shutdownĮlixir conventions structure your projects as small composable “applications” that can be started and stopped as a unit. ![]() With no global state or global servers, you can break your application into pieces as your infrastructure grows. A new Phoenix application will include one Endpoint, one Router, and one PubSub Server, but you are free to add more. If you need sharing, you need to carefully break it apart into engines and learn a new set of rules. As an inherent limitation of this approach, you cannot run two Rails applications side by side. Rails runs the show, from starting the application, configuration, and even running command line tasks. In Rails there is a single application that’s accessible via Rails.application. This means there is one way to build, run, and deploy your applications – the Elixir way. Your Phoenix projects are first and foremost Elixir applications, which relies on Phoenix to provide part of its functionality. There is no such thing as a “Phoenix application”. This deviation from Rails has effects throughout the stack. We embrace Elixir and OTP conventions in Phoenix so that your Phoenix application is only a component of your greater application infrastructure. From how you structure your applications, recover from failure, debug your systems, or talk to a remote client, Phoenix takes an approach that few run-times can offer. With a few similarities, comes major differences.
0 Comments
Leave a Reply. |