github.com/nycdavid/zeus@v0.0.0-20201208104106-9ba439429e03/docs/ruby/modifying.md (about)

     1  # Modifying the boot process
     2  
     3  Running `zeus init` creates a default [`zeus.json`](../../examples/custom_plan/zeus.json) and [`custom_plan.rb`](../../examples/custom_plan/custom_plan.rb) that define the boot order for your application. 
     4  
     5  Each node under "plan" in the JSON file has an action associated with it. You can see the "command" value at the top of the hash requires `"./custom_plan.rb"`. Inspecting that file, you can see that it creates an empty subclass of `Zeus::Rails`. If you look at [that file](../../rubygem/lib/zeus/rails.rb), you will see a class with a method name corresponding to each node -- something along the lines of:
     6  
     7  ```ruby
     8  class Zeus::Rails < Zeus::Plan
     9    def boot
    10      # ...
    11    end
    12    def default_bundle
    13      # ...
    14    end
    15    # ...
    16  end
    17  ```
    18  
    19  Note that an instance of the subclass class is assigned to `Zeus.plan` at the end of `custom_plan.rb`. Zeus calls methods on `Zeus.plan` to boot the application. If you follow any path to a leaf node in the tree -- for example, boot, default_bundle, development_environment, prerake -- those methods are essentially called in sequence to construct an environment for a command (rake, in this case) to run in. Zeus forks the ruby process between each step, and can restart from any of these forks.
    20  
    21  You can modify the plan by adding/removing/moving nodes in the json file and adding the corresponding methods in `custom_plan.rb`.
    22  
    23  ```ruby
    24  # custom_plan.rb
    25  require 'zeus/rails'
    26  class CustomPlan < Zeus::Rails
    27    def boot
    28      something_else
    29    end
    30  end
    31  Zeus.plan = CustomPlan.new
    32  ```
    33  
    34  Note that there's nothing special about the naming or location of `CustomPlan`. Feel free to rename and/or move as you please, just remember to update the `command` line in `zeus.json` -- and `zeus.json` must stay at your project root, or Zeus will just use the default configuration.