Erlang: How to dynamically switch between multiple versions of module/Application

Source: Internet
Author: User

Problem:

Different Versions of applications need to be dynamically loaded in the system, mainly because of interface changes.

Solution:

1. Switch the view in clearcase to select different versions.

2. Remove this app from the control of clearcase. Different versions are differentiated by different directories.

Feasibility analysis phase:

The first solution was quickly abandoned. A single user switched views well, but the system was a multi-user. There was no effective way to control the apps under multiple views: (if anyone knows, please tell me :)


-------------
APP (viewb), user1

For example, modulea (viewa) ------------- app (viewc), user2

The second solution is feasible.

The main idea is to make this app independent from the version control of clearcase, which does not need to be switched in different views. The system only needs to dynamically load the app in the corresponding path based on the version specified by the user. It can be used to detect the version change of the app in clearcase and create the corresponding path, is not part of the system.

The characteristics of dynamic loading in Erlang mainly in the Code module, detailed can refer to the http://www.erlang.org official explanation. This module is mainly an interface provided by code server and is responsible for beam File Path Management in the Erlang system.

For specific problems, the idea is as follows:

If the system already contains the module path, uninstall it: code:Del_path

Load the new path code: add_path, and then update code: rehash.

In addition, when starting with ERL, do not use PZ to include the path of this module, which may lead to invalid (not carefully studied). We recommend that you use this dynamically specified method.

After updating the module path, you can use it normally.


PS:

You need to delete the module and use code: delete. I used init: Stop to kill this node for easy reasons, so I don't need :)

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.