Comments (5)
Sourcing all plugins could prove problematic sooner than later.
Have you considered an inverse approach? Similar to how git commands work. Git has core commands that are shipped with it. In addition, it can search the $PATH
for executables that match git-*
and they can be run as git <external command name>
.
The reason I call this approach inverse is that instead of sourcing everything into the core script, you will run each external script separately, possibly sourcing in some core functionality common to all scripts.
Using this architecture, the core set of commands could be made rather granular, so that plugin commands would be able to call specific ones at different points in their execution.
from exrm.
I have not come across any need to a boot script yet that must be executed as part of the elixir/erlang install. I do have scripts that run during installation, but since I package in an rpm, I have the capability to run scripts with it.
Do you have any examples?
BTW, I like @alco's suggestion...
from exrm.
@alco I like that approach a lot better. What would be the approach for getting common functionality sourced into the plugins? I suppose since the plugins would live in a predictable location of the release bin directory, they could just source the core script via relative path.
I suppose the idea here then would be that all of the individual boot tasks that already exist would be extracted in to plugins, and the boot script would be pared down to just looking up the plugin script for the requested command? Yeah, definitely a fan.
@smpallen99 The example I used above of how conform is executed in the boot script prior to commands which start the app is a good one. Basically I'm using environment variables set up in the prelude of the boot script from a custom function, which will compose and execute the command to convert .conf/.schema.exs files to a final sys.config on boot. Right now this stuff is injected into the body of each command's handler. It would be nice if I could keep the boot script free of custom stuff like that, and make it general enough so that other plugin authors could offer similar functionality if needed. Perhaps my case is the only one which needs it, but I kind of doubt it.
@alco Speaking of the conform example, how would that be accomplished with the git-like architecture? Since conform needs to run anytime the VM is booted, I could perhaps accomplish it by making the app start commands part of the core functionality, and just include the conform stuff there, but I would like it if I could pull it out as some kind of plugin.
Thanks for the thoughts guys!
from exrm.
Multiple approaches are possible depending on how granular or powerful you want plugins to be.
I can imagine two structures.
- Have a common setup in the boot script and then
exec
a plugin:
# boot.sh
export SOME_VAR=...
function some_func() {
}
plugin=${1#boot-}
shift 1
exec plugin_dir/$plugin $@
# boot-plugin1
# do something here, can call other plugins
# not sure exactly how though
$ ./boot.sh plugin1
With this approach, composability comes with the ability for plugins to call other plugins.
- Use hooks for plugins
# boot.sh
# do some setup
# call all scripts that have registered for "post-setup" hook
call_hooks "post-setup"
# prepare command invocation
# ...
call_hooks "pre-command"
# run command
# ...
Here you let plugins to register for certain steps on the way to executing the requested command. The commands themselves can still reside in separate scripts allowing for 3rd party commands to be added.
I can't say at the moment how the core state will be shared with multiple plugin or hook invocations. Perhaps looking at Git's source could shed some light on it.
from exrm.
I'm going to tentatively close this for now. At the time I wanted to build out our own bootscript, but I'd rather try to maintain some parity with relx's boot script for maintenance. If this becomes a common request, we can revisit it then.
from exrm.
Related Issues (20)
- Mix.env/1 being used with string instead of atom when `--env="prod"` passed from script HOT 1
- Generating upgrade fails when attaching git revision to version HOT 1
- "/rel/<projectname>/bin/<projectname> stop" does not work HOT 3
- `mix release` fails with `{unreachable_package, cowlib}` HOT 4
- Error when following Phoenix Walkthrough Documentation
- [Bug?] Not responding to pings HOT 1
- RELX_REPLACE_OS_VARS boot script fails on awk with env vars containing certain characters HOT 3
- Color codes always output
- Release on ubuntu but cannot use in macOS HOT 2
- Can't generate release if config contains values set by an anonymous function HOT 3
- Remote console doesn't seem to have access to all applications in an umbrella app HOT 1
- Running mix release in docker cause MatchError. HOT 1
- Upgrade releases and storage... HOT 1
- deploy: module Experimental.Flow is not available
- mix release fails with 'no case clause matching: :eacces' HOT 8
- Raspbian Jessie with erlang 19 failed to start release HOT 1
- using a different erts version when deploying a release
- Default protocols are not replaced by consolidated in release. HOT 3
- Error while trying to rewrite app file HOT 2
- Mix.Shell.cmd/2 no longer exists, could we get an update to use the new Mix.Shell.cmd/3?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exrm.