Fuge's  apply command

The apply command allows us to execute any shell command in every directory of each named service.

This sometimes come in very useful, but it should be used carefully.

We can try this by spinning up the Fuge shell:

$ fuge shell fuge.yml # assuming working dir is micro/fuge 

Then, in the shell we can use apply to (for instance) output the directory contents of every registered service:

 fuge> apply ls -l
[adderservice]
total 16
drwxr-xr-x 52 pelger staff 1768 24 Mar 13:33 node_modules
-rw-r--r-- 1 pelger staff 313 24 Mar 13:34 package.json
-rw-r--r-- 1 pelger staff 399 24 Mar 13:33 service.js
[webapp]
total 16
-rw-r--r-- 1 pelger staff 1313 24 Mar 13:33 app.js
drwxr-xr-x 3 pelger staff 102 24 Mar 13:33 bin
drwxr-xr-x 98 pelger staff 3332 24 Mar 13:33 node_modules
-rw-r--r-- 1 pelger staff 349 24 Mar 13:33 package.json
drwxr-xr-x 5 pelger staff 170 24 Mar 13:33 public
drwxr-xr-x 5 pelger staff 170 24 Mar 13:33 routes
drwxr-xr-x 5 pelger staff 170 24 Mar 13:33 views

The utility of this becomes apparent once we have a larger (greater than 5) number of services, particularly if they are using separate Git repositories.

For example running apply git status will give us an immediate view of the current changes on our local system.

Another useful example is apply npm test to run all of the unit tests in one go across our system, and apply npm install if we've checked out a fresh system and want to install the dependencies of each service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.5.86