blob: 9279cd6e3d70a6483bf415250475e1b1b2319fca [file] [log] [blame] [view]
Przemyslaw Pietrzkiewicz214e8f12015-09-14 13:55:05 +02001# mojo_run
2
3`mojo_run` allows you to run a Mojo shell either on the host, or on an attached
4Android device.
5
6```sh
Przemyslaw Pietrzkiewiczda012592016-04-02 00:54:23 +02007mojo_run APP_URL # Run on Linux host.
Przemyslaw Pietrzkiewicz214e8f12015-09-14 13:55:05 +02008mojo_run APP_URL --android # Run on Android device.
9mojo_run "APP_URL APP_ARGUMENTS" # Run an app with startup arguments
10```
11
Przemyslaw Pietrzkiewiczda012592016-04-02 00:54:23 +020012## mojo version
13
14`mojo_run` will download mojo shell and configure it to use `mojo:` apps built
15at the corresponding version, if you pass the git commit sha of the
16https://github.com/domokit/mojo repository as `--mojo-version`:
Przemyslaw Pietrzkiewicz214e8f12015-09-14 13:55:05 +020017
18```sh
Przemyslaw Pietrzkiewiczda012592016-04-02 00:54:23 +020019mojo_run APP_URL --mojo-version SOME_HASH
Przemyslaw Pietrzkiewicz214e8f12015-09-14 13:55:05 +020020```
21
Przemyslaw Pietrzkiewiczda012592016-04-02 00:54:23 +020022If your project uses a pinned version of mojo, you can put the pinned hash in
23a `MOJO_VERSION` file in any ancestor directory of `mojo_run`. This will make
24`mojo_run` infer the parameter automatically.
25
26If you don't want to use prebuilt binaries at the given version, you can
27configure the shell binary and the origin to use manually:
28
29```sh
30mojo_run APP_URL --shell-path path/to/shell/binary --origin ORIGIN_URL
31```
32
33## Running applications in a view
34
Przemyslaw Pietrzkiewicz35216612016-03-10 17:39:17 +010035Some applications implement ViewProvider and are run embedded in a view. To run
36these, you can pass the app url using the `--embed` flag:
Przemyslaw Pietrzkiewicz214e8f12015-09-14 13:55:05 +020037
38```sh
39mojo_run --embed APP_URL [--android]
40```
41
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010042## Running multiple instances simultaneously
Przemyslaw Pietrzkiewiczeec06de2015-10-14 09:53:55 -070043
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010044`mojo_run` sets up development servers on fixed ports to facilitate caching
45between runs and allow the script to work remotely using `adb_remote_setup`.
46This would normally prevent two or more instances of `mojo_run` from running
47simulatenously as the development servers cannot be spawned twice on the same
48ports.
49
50In order to run the same set of binaries simultaneously one can use the
51`--reuse-servers` switch for second and further instances. This will make the
52second and further instances assume that development servers are already
53spawned.
54
55On **Android** one needs to indicate the id of the device to be targeted in each
56run. For example, we could run the following in one shell:
Przemyslaw Pietrzkiewiczeec06de2015-10-14 09:53:55 -070057
58```sh
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010059mojo_run APP_URL --android --target-device DEVICE_ID
Przemyslaw Pietrzkiewiczeec06de2015-10-14 09:53:55 -070060```
61
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010062and the following in another:
63
Przemyslaw Pietrzkiewiczeec06de2015-10-14 09:53:55 -070064```sh
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010065mojo_run APP_URL --android --target-device ANOTHER_DEVICE_ID --reuse-servers
Przemyslaw Pietrzkiewiczeec06de2015-10-14 09:53:55 -070066```
67
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010068Device id can be obtained from `adb devices`.
Przemyslaw Pietrzkiewiczeec06de2015-10-14 09:53:55 -070069
Przemyslaw Pietrzkiewiczb8020252015-11-09 17:18:28 +010070On **Linux** one needs to use a different $HOME directory for each run, to avoid
71collision of the cache storage. For example, we could run the following in one
72shell:
73
74```sh
75mojo_run APP_URL
76```
77
78and the following in another:
79
80```sh
81mkdir ~/another_home
82HOME=~/another_home mojo_run APP_URL --reuse-servers
83```