summaryrefslogtreecommitdiff
path: root/src/rebar_prv_shell.erl
Commit message (Collapse)AuthorAgeFilesLines
* Attempt at support sys_config_src in shellFred Hebert2019-03-221-3/+73
|
* Merge pull request #2011 from ferd/release-switch-in-shellFred Hebert2019-02-041-6/+27
|\ | | | | Add --relvsn and --relname to rebar3 shell
| * Add --relvsn and --relname to rebar3 shellFred Hebert2019-01-311-6/+27
| | | | | | | | | | | | | | Allows to select one of many releases conditionally. Default behaviour should be unchanged from existing one. Can filter on only the version or only the name, or both.
* | Unhang logger when swapping the TTY in shellFred Hebert2019-01-311-1/+23
|/ | | | | | | | | | | | | | | | | Starting with OTP-21.2.3, some output appears to be sent to the shell while we're taking down the TTY, which ends up stalling the whole log flow for the default handler. I don't have proof but suspect this is due to the system logging going directly from the ERTS runtime to the logger, which may be trigger when we kill the TTY driver. This patch makes it so whenever we detect that logger is active, we save the default config, disable the default logger, and only then we can kill the TTY driver. Once the driver is started and all the group leaders have been rewritten, the default logger is re-added. This all takes place _before_ the logger configuration is updated as part of booting apps, and the change should be fully backwards compatible.
* support for hex v2, multiple repository fetching, private organizations (#1884)Tristan Sloughter2018-09-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
* Reload logger config in shellFred Hebert2018-09-101-1/+1
| | | | | | | | | | | | | This requires some fancy dynamic work since the logger is started as part of the kernel and we lost the sys.config from users when working from there. We start conservatively by making it an optional thing, turning it on only where we know it to be safe. The changes are applied _after_ having loaded the rest of configs so if an inoffensive error happens, the shell works (with a bad error message) rather than plain exploding.
* Add --start-clean flag to rebar3 shellFred Hebert2018-06-051-2/+10
| | | | | | | Allows override of apps specified in other on-disk options. Equivalent to `--apps=""` Fixes #1785
* Logger OTP-21-rc2 supportFred Hebert2018-05-301-1/+1
| | | | Also small output fix in rebar3 shell
* Confirm lack of regressions on new logger in shellFred Hebert2018-05-031-9/+16
|
* Work around OTP-21 deprecation of get_stacktrace()Fred Hebert2018-05-031-4/+4
| | | | Based off a macro by @okeuday at https://github.com/erlang/otp/pull/1783
* Reload apps running in shell with new configFred Hebert2018-04-201-3/+28
| | | | | | | This patch makes it so that whenever the rebar3 shell has a new configuration for an application that is already running and would be restarted (without risking the stability of the node or functionality of rebar_agent), we stop and restart the app.
* OTP-21 readiness, Full Unicode supportFred Hebert2017-11-161-1/+1
| | | | | | | | | | | | This replaces all deprecated function usage by alternative ones based on a version switch enacted at compile time, preventing all warnings. This will likely introduce some possible runtime errors in using a Rebar3 compiled on OTP-20 or OTP-21 back in versions 19 and earlier, but we can't really work around that. A bunch of dependencies have been updated to support OTP-21 without warnings as well.
* fix `rebar3 shell` when relx section of rebar.config contains releases with ↵patrick cieplak2017-08-171-0/+3
| | | | independent configurations
* Application type of none was not working.Anthony Molinaro2017-06-151-1/+4
| | | | | | | | | | | | I noticed this when trying to include entop in a release. Entop uses cecho which takes over the terminal, so you do not want it loaded or started. According to http://erlang.org/doc/man/rel.html, when you specify a Type of none it should not load or start, but the code for it's modules should be loaded. This patch ensures the code is not loaded or started, but doesn't do anything with the code paths. At the very least this allows me to start a shell in the case where I have an application of type none, and the application is neither loaded nor started.
* add option to pass args to user_drv for custom shellsTristan Sloughter2016-12-311-6/+16
|
* Merge pull request #1415 from lrascao/feature/rebar_shell_fixFred Hebert2016-12-161-0/+4
|\ | | | | shell: don't crash apps that use release version operators
| * shell: don't crash apps that use release version operatorsLuis Rascao2016-12-111-0/+4
| | | | | | | | Like for instance: {app, "0.1.0", '='}
* | the releases website has changedgetong2016-12-141-1/+1
|/
* Fix rebar3 dialyzer warningsFred Hebert2016-11-191-1/+1
| | | | Some tricky changes in there but should be okay
* ignore return value of `rebar_utils:reread_config` in shell provideralisdair sullivan2016-06-121-1/+2
|
* add support for passing a sys_config to common testTristan Sloughter2016-06-111-28/+4
|
* Fix shell node startupCarlos Gonzalez2016-05-091-0/+4
|
* Fixes logging from remote shells in rebar3 shellFred Hebert2016-04-131-1/+3
| | | | | Somehow swapping the tty handler once more fixes everything. I guess we were missing a step somehow.
* Recursively load configurations in shell.Benedikt Reinartz2016-04-071-5/+12
| | | | | The sys.config loading in the shell command did not implement recursion and thus processed the file different from a `erl -config cfg/path`.
* Extract dist config handling, support {dist, ...}Fred Hebert2016-03-211-27/+2
| | | | | | | | | | | | | | | | | | This commit moves the handling of distribution config and starting out of rebar_prv_shell and into rebar_dist_utils. The module is able to handle standard config options and boot a distributed node mode. This could be used in plugins (once it is exposed) and other providers like CT. Configuration is also expanded so that options like: {dist, [{sname, atom()}, {name, atom()}, {setcookie, term()}]} can be used and will be handled as a default. The config handler supports similar terms from the command line being parsed in if the calling provider supports them. A test suite is added for configuration handling.
* Fix bugs/race conditionsFred Hebert2016-03-191-2/+16
| | | | | | | | | | Following suggestions from @psyeugenic, this code terminates and waits for the termination of the port handling IO before booting our own, which should get rid of annoying warnings. We also allow for the failure to shutdown the user worker under kernel_sup, since it is likely not there anymore in many scenarios, preventing crashes.
* Support --setcookie optionFred Hebert2016-02-211-2/+14
| | | | Replicates `erl` behaviour.
* Display error message when bad config is loadedFred Hebert2016-01-171-2/+7
| | | | | | | | | | | | | | | | If a bad configuration file is submitted to rebar3 shell, display the following error: ===> The configuration file submitted could not be read and will be ignored. And keep going otherwise rather than silently failing. While crash-fast is usually a good mechanism, the shell so far is very tolerant of failures from apps to boot and whatnot, so this feels appropriate. Fixes #1019
* Correct TTY type detectionFred Hebert2016-01-061-17/+23
| | | | | | | | | | | | | | This reuses the trick used within OTP to pick within old and new shell. The 'user' structure is the same for all cases (escript, escript + dumb TERM, unstable install, unstable install + dumb TERM), so we take it down first. Then we boot the TTY driver, which fails if TERM=dumb, in which case we boot the retro-style usr. If it worked, we shut down the driver again, and boot a modern shell structure. This avoids all warnings and seems to work in all cases.
* Support old-style shell for rebar3 shellFred Hebert2016-01-061-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is quite the hack. This requires to detect the current shell running; if it's the new shell, business as usual. However, if it's the old shell, we have to find a way to take over it and drive IO. This requires a few steps because: - the old shell does not let you be supervised intelligently (it uses supervisor_bridge, so killing the child is not a supported operation from the supervisor) - the old shell ignores all trappable exit signals except those coming from the Port in charge of stdio ({fd, 0, 1}) - the old shell shuts down on all exit signals from the stdio Port except for badsig, and replicates the shutdown reason otherwise - An escript does not tolerate the `user` process dying (old shell) for any non-normal reason without also taking the whole escript down - Booting in an escript has an implicit 'noshell' argument interpreted by the old shell as a way to boot the stdio Port with only stdout taken care of Because of all these points, we have to kill the old `user` process by sending it a message pretending to be the Stdio port dying of reason `normal`, which lets it die without triggering the ire of its supervision tree and keeping the escript alive. This, in turn, kills the old stdio port since its parent (user.erl) has died. Then we have to boot our copy of user.erl (rebar_user.erl) which conveniently ignores the possibility of running the stdio port on stdout only -- always using stdin *and* stdout, giving us a bona fide old-style shell. A known issue introduced is that running r3:do(ct) seems to then kill the shell, and r3:do(dialyzer) appears to have an odd failure, but otherwise most other commands appear to work fine.
* Fix IO locking up in shell appsFred Hebert2015-11-141-5/+19
| | | | | | | | | | | | | | | | | | | | | Application masters are booted at the root of apps, and take over the group leader role to redirect IO. To cut the chain short and properly have their role inherited, they are their own leader, and keep a reference to the old leader in their internal state, which we cannot change. This is done so process ownership to a given application can be established, and allows to properly clean up resources outside the supervision tree when an app is shut down. This patch goes around and finds all processes whose group leaders are application masters older than the new `user' process booted by the shell providers, and swaps them with that new `user'. This lets the application masters survive, and fixes the blocking IO issue (resolving issue #899) This may mean an incomplete clean up is down on application shutdown, but that seems like a fair compromise.
* Feature: rebar shell [--script <FILE>]Geoff Cant2015-11-131-29/+131
| | | | | | | | | | | | | | | | | Adds the ability to run an escript before starting the apps and interactive shell for a project. This is intended to improve the local development experience for projects by providing an easy way to run companion services (mock rest APIs, databases etc) that the project relies on. This patch also adds {shell, Defaults} to the rebar config file so that a project can supply default values for many of the new or improved 'rebar3 shell' options: * {apps, OTPApps} * {script_file, EscriptFileName} * {config, ConfigFileName} The order of option precedence is command line, rebar.config, relx.
* Shell handles all possible relx app formatsFred Hebert2015-09-261-2/+15
| | | | | | | | | The list of applications in the relx config section could contain tuples. The tuple will either contain a version constraint for the app, the start type of the app or both. This fix silently expands `{shell_apps, [Apps]}` to support the same format.
* fix dialyzer warnings, except 'no local return' warningsTristan Sloughter2015-08-081-1/+1
|
* Detect missing EPMD, error, fallback and advise.Fred Hebert2015-08-051-2/+8
|
* Run agent as current process & hibernateFred Hebert2015-07-031-3/+9
| | | | | | | This tries to reduce memory usage when running `rebar3 shell` by running the agent in the current process (and avoiding to copy state cross-boundaries), and using frequent hibernation after each run to force a full GC and compaction of the current process.
* OTP apps show proper outputFred Hebert2015-06-151-1/+4
| | | | | | | | | | Whenever the old shell got killed and an app got loaded prior, the whole thing would silently drop output as the old 'user' process was replaced while application master processes would keep the old one's pid in their internal state. To work around this limitation, make sure the apps are booted only after the shell is replaced so that only the new `user` pid is used.
* Handle custom logger shell breakageFred Hebert2015-06-011-6/+12
| | | | | | | When swapping handlers, if a custom shell has been installed, it's possible it'll take over the tty and other options. This may break common operations that work on an otherwise regular shell, so we ignore failures and let things work with the custom shell only.
* Merge pull request #487 from ferd/fix-provider-barenessTristan Sloughter2015-05-301-1/+1
|\ | | | | fix bareness issues
| * fix bareness issuesFred Hebert2015-05-311-1/+1
| | | | | | | | | | | | - Crashes in providers lib when no providers in a namespace are bare - Making sure bareness matches semantics; i.e. a bare provider is visible, a non-bare provider is hidden.
* | Fix badarg exception when setting group_leader for a dead pidAndras Boroska2015-05-301-2/+4
|/ | | | | | When setting up a shell some time elapses between listing the pids and setting the group_leader. If the process exited during that time then erlang:group_leader/2 will crash with badarg.
* Optionally allow node names to the rebar3 shell.Fred Hebert2015-05-301-12/+30
| | | | | Helps with integration efforts, but unfortunately can't support the '-sname' and '-name' options, only '--sname' and '--name'.
* Fix config loading in shellFred Hebert2015-05-301-1/+4
| | | | | | | | | | | | | | | Config files from the command line would expect the wrong format: {app1, [...]}. {app2, [...]}. Instead of the correct sys.config format: [{app1, [...]}, {app2, [...]}] Not supported yet: the recursive file references documented in http://www.erlang.org/doc/man/config.html
* Add support to boot apps from releases in shellFred Hebert2015-05-291-1/+14
| | | | Precedence still goes to shell_apps.
* Get prebooted apps to acknowledge sys.configFred Hebert2015-05-291-3/+16
| | | | | Change the order from load-config -> start-apps to load-apps -> load-config -> start-apps
* Rebar agent reloads the config file on every runFred Hebert2015-05-281-1/+1
| | | | | This allows proper checking of new configurations, deps, or plugins, and makes sure they are detected during an active shell session.
* Add a shell agentFred Hebert2015-05-261-10/+14
| | | | | The shell agent allows to run rebar3 commands and autoload compiled modules when that is done.
* Adding app auto-boot to rebar shellFred Hebert2015-05-231-35/+63
| | | | | | | | | | - moved path addition, config loading and app boot to before the shell is available - apps successfully booting are in an INFO message, failed to boot into an ERROR message - A warning is printed when apps are booted informing to please use releases for actual deployment, and is omitted otherwise. - Some minor refactorings otherwise.
* print and format error message for bad .app files and all bad configsTristan Sloughter2015-05-221-15/+6
|
* try to read a config file when running `rebar shell`Nathaniel Waisbrot2015-05-071-1/+61
| | | | | | Adds a `--config` flag to the shell command to specify a config file. If the flag is not specified, attempts to read the sys_config defined for relx.