How can I perform hot reload code in tarantool cartridge without restarting application ?
How can I perform hot reload code in tarantool cartridge?
458 Views Asked by Aleksey Budaev At
1
There are 1 best solutions below
Related Questions in TARANTOOL
- Why I cannot type assert empty interface?
- Connection refused [Tarantool + java client]
- Can I use Tarantool instead of Redis?
- Tarantool Data Modelling Relationships
- tarantool queue attempt to index global 'queue'
- overriding configuration on a running tarantool instance
- How to create sharded-queue tube the right way?
- How to implement default config section for a custom Tarantool Cartridge role?
- delete() from the script and the interpretator gives a different result. Why?
- How to implement pagination for multikey indexes in Tarantool?
- Sending messages to handler function fibers in TCP server
- Can I yield during an transaction in Tarantool?
- How to make a fault tolerant Tarantool cluster
- How to remove a field in Tarantool space?
- Tarantool does not start due to disk write error
Related Questions in TARANTOOL-CARTRIDGE
- How to create sharded-queue tube the right way?
- How to implement default config section for a custom Tarantool Cartridge role?
- How to make a fault tolerant Tarantool cluster
- How to remove a field in Tarantool space?
- Cartrige instances.yml file
- Custom response from Tarantool + Nginx
- icu_date gives an error message attempt to index a number value
- Using Tarantool http as Nginx upstream server - got error 13: Permission denied
- Tarantool Cartridge "Memory is highly fragmented" errors
- How can I perform hot reload code in tarantool cartridge?
- How to return the table with tuples of the SELECT()?
- How to use tarantool command <cartridge replicasets join> in docker with multi container?
- Evolving Tarantool instance
- Tarantool cartridge-springdata(spring data for tarantool) does not work when language is kotlin
- Why does my Tarantool Cartridge retrieve data from router instance sometimes?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
In order to find the best solution to your problem it is important to understand what you are trying to achieve. There are 2 possible scenarios:
The first one can be done by unloading a module and loading it again. All modules, when loaded, place themselves to the 'package.loaded' table. So all you need is to update it:
This is a low-level approach that you can generalize: loop over contents of 'package.loaded', unload everything and load it back again. You need to be careful here to not unload the modules that are not present on a filesystem. There is a module that can help you with this: https://github.com/moonlibs/package-reload
While that module will help you with the basics, there are other things you need to consider. In Lua it is very easy to store function pointers inside global objects. If you reload the function itself, you won't magically update all the places that have the pointer to the old function. For example, let's consider the http server:
If you reload mymodule.lua, and not call the router:route again to re-register the handler, HTTP requests will still call the old function.
In cartridge, you usually register functions in apply_config() or init(). See here for example. In order to re-register the callbacks you need to call init() or apply_config() of your roles again. To get a list of roles, you can use cartridge.roles.get_known_roles() . You need to loop over them and re-init them.
In order to call the function that reloads the code, you'll either need to connect through the binary protocol, or use admin socket. Admin socket allows you to write a simple shell script for that. You can get the idea by looking at the tarantool_is_up script . It demonstrates the approach that you can adapt for your use-case.
The second way to achieve this will be to use cartridge-extensions that allows you to push new code through network. It already has some niceties like simplified binding to the public endpoints.