Przemyslaw Pietrzkiewicz | 214e8f1 | 2015-09-14 13:55:05 +0200 | [diff] [blame] | 1 | # mojo_run |
| 2 | |
| 3 | `mojo_run` allows you to run a Mojo shell either on the host, or on an attached |
| 4 | Android device. |
| 5 | |
| 6 | ```sh |
Przemyslaw Pietrzkiewicz | da01259 | 2016-04-02 00:54:23 +0200 | [diff] [blame] | 7 | mojo_run APP_URL # Run on Linux host. |
Przemyslaw Pietrzkiewicz | 214e8f1 | 2015-09-14 13:55:05 +0200 | [diff] [blame] | 8 | mojo_run APP_URL --android # Run on Android device. |
| 9 | mojo_run "APP_URL APP_ARGUMENTS" # Run an app with startup arguments |
| 10 | ``` |
| 11 | |
Przemyslaw Pietrzkiewicz | da01259 | 2016-04-02 00:54:23 +0200 | [diff] [blame] | 12 | ## mojo version |
| 13 | |
| 14 | `mojo_run` will download mojo shell and configure it to use `mojo:` apps built |
| 15 | at the corresponding version, if you pass the git commit sha of the |
| 16 | https://github.com/domokit/mojo repository as `--mojo-version`: |
Przemyslaw Pietrzkiewicz | 214e8f1 | 2015-09-14 13:55:05 +0200 | [diff] [blame] | 17 | |
| 18 | ```sh |
Przemyslaw Pietrzkiewicz | da01259 | 2016-04-02 00:54:23 +0200 | [diff] [blame] | 19 | mojo_run APP_URL --mojo-version SOME_HASH |
Przemyslaw Pietrzkiewicz | 214e8f1 | 2015-09-14 13:55:05 +0200 | [diff] [blame] | 20 | ``` |
| 21 | |
Przemyslaw Pietrzkiewicz | da01259 | 2016-04-02 00:54:23 +0200 | [diff] [blame] | 22 | If your project uses a pinned version of mojo, you can put the pinned hash in |
| 23 | a `MOJO_VERSION` file in any ancestor directory of `mojo_run`. This will make |
| 24 | `mojo_run` infer the parameter automatically. |
| 25 | |
| 26 | If you don't want to use prebuilt binaries at the given version, you can |
| 27 | configure the shell binary and the origin to use manually: |
| 28 | |
| 29 | ```sh |
| 30 | mojo_run APP_URL --shell-path path/to/shell/binary --origin ORIGIN_URL |
| 31 | ``` |
| 32 | |
| 33 | ## Running applications in a view |
| 34 | |
Przemyslaw Pietrzkiewicz | 3521661 | 2016-03-10 17:39:17 +0100 | [diff] [blame] | 35 | Some applications implement ViewProvider and are run embedded in a view. To run |
| 36 | these, you can pass the app url using the `--embed` flag: |
Przemyslaw Pietrzkiewicz | 214e8f1 | 2015-09-14 13:55:05 +0200 | [diff] [blame] | 37 | |
| 38 | ```sh |
| 39 | mojo_run --embed APP_URL [--android] |
| 40 | ``` |
| 41 | |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 42 | ## Running multiple instances simultaneously |
Przemyslaw Pietrzkiewicz | eec06de | 2015-10-14 09:53:55 -0700 | [diff] [blame] | 43 | |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 44 | `mojo_run` sets up development servers on fixed ports to facilitate caching |
| 45 | between runs and allow the script to work remotely using `adb_remote_setup`. |
| 46 | This would normally prevent two or more instances of `mojo_run` from running |
| 47 | simulatenously as the development servers cannot be spawned twice on the same |
| 48 | ports. |
| 49 | |
| 50 | In 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 |
| 52 | second and further instances assume that development servers are already |
| 53 | spawned. |
| 54 | |
| 55 | On **Android** one needs to indicate the id of the device to be targeted in each |
| 56 | run. For example, we could run the following in one shell: |
Przemyslaw Pietrzkiewicz | eec06de | 2015-10-14 09:53:55 -0700 | [diff] [blame] | 57 | |
| 58 | ```sh |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 59 | mojo_run APP_URL --android --target-device DEVICE_ID |
Przemyslaw Pietrzkiewicz | eec06de | 2015-10-14 09:53:55 -0700 | [diff] [blame] | 60 | ``` |
| 61 | |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 62 | and the following in another: |
| 63 | |
Przemyslaw Pietrzkiewicz | eec06de | 2015-10-14 09:53:55 -0700 | [diff] [blame] | 64 | ```sh |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 65 | mojo_run APP_URL --android --target-device ANOTHER_DEVICE_ID --reuse-servers |
Przemyslaw Pietrzkiewicz | eec06de | 2015-10-14 09:53:55 -0700 | [diff] [blame] | 66 | ``` |
| 67 | |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 68 | Device id can be obtained from `adb devices`. |
Przemyslaw Pietrzkiewicz | eec06de | 2015-10-14 09:53:55 -0700 | [diff] [blame] | 69 | |
Przemyslaw Pietrzkiewicz | b802025 | 2015-11-09 17:18:28 +0100 | [diff] [blame] | 70 | On **Linux** one needs to use a different $HOME directory for each run, to avoid |
| 71 | collision of the cache storage. For example, we could run the following in one |
| 72 | shell: |
| 73 | |
| 74 | ```sh |
| 75 | mojo_run APP_URL |
| 76 | ``` |
| 77 | |
| 78 | and the following in another: |
| 79 | |
| 80 | ```sh |
| 81 | mkdir ~/another_home |
| 82 | HOME=~/another_home mojo_run APP_URL --reuse-servers |
| 83 | ``` |