How to run the Director?

The page Concepts >> Director says, “The director can be run inside of a supervisor as well.”, but goes on to warn of special considerations, “However, child supervisor processes will use the same IP address of the director. etc”

The page Run packages >> Run multiple packages using the director >> Using the director says, “When run in a supervisor, the director can be started using the hab start command”

hab start core/hab-director

The Concepts section wording suggests that it’s better to not run the Director in a supervisor, but then the only execution instructions are for starting within a supervisor.

What’s the right thing to do here?

What’s the command to start a self-standing Director?

Hello -

The easiest way to start the Director is:

    hab start core/hab-director

This runs the Director in a Habitat supervisor, so you can dynamically configure, create a ring etc.

To start it manually, you can just exec the Director binary:

    # you may need to install the director first:
    # hab install core/hab-director
   /hab/pkgs/core/hab-director/0.9.1/20160901211337/bin/hab-director

The version/release will most likely change in the future, which changes the path to the binary.

Cheers -
Dave

Dave,

Once again, thank you!

So, the remarks like, “…can be run inside of a supervisor as well…” and “When run in a supervisor…”, are just misleading? Running in a supervisor is the normal, correct way to do it, not a secondary, unusual option?

So, I tried…

 hab start core/hab-director

…getting…

hab-sup(GS): Starting gossip failure detector
hab-sup(CN): Starting census health adjuster
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited

Then I tried …

 hab start core/hab-director ./default.toml

…but got…

error: Found argument './default.toml' which wasn't expected, or isn't valid in this context

USAGE:
    hab-sup start <pkg_ident_or_artifact> --permanent-peer

For more information try --help

How do I run the Director?

Hello -

See the “Using the Director” section of the docs [0]. You’ll need to apply the config file via hab config apply after you start the director. We’re working on making this easier in a future release by specifying a toml file as part of the hab start command (like you tried above).

    hab start core/hab-director
    hab config apply hab-director.default --peer 172.17.0.2 1 /path/to/config.toml

Where 172.17.0.2 is the IP of the current node (don’t use 127.0.0.1).

Cheers -
Dave

[0] https://www.habitat.sh/docs/run-packages-director/

So I just ignore the hemorrhage of error messages ?

you@yourhost:~/projects/todos$ sudo hab start core/hab-director
hab-sup(MN): Starting core/hab-director
hab-sup(TP): Child process will run as user=root, group=hab
hab-sup(GS): Supervisor 192.168.122.198: 9e8f6c94-b42a-4239-98d7-df57ac39fc4f
hab-sup(GS): Census hab-director.default: 47d81527-5d14-43ab-a305-b9c5a5c4e0e8
hab-sup(GS): Starting inbound gossip listener
hab-sup(GS): Starting outbound gossip distributor
hab-sup(GS): Starting gossip failure detector
hab-sup(CN): Starting census health adjuster
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited
hab-director(SV): Starting
hab-director(O): No services specified in configuration
hab-sup(SV): hab-director - process 27159 died with exit code 1
hab-sup(SV): hab-director - Service exited
     :                :                   :

     :                :                   :

     :                :                   :

     :                :                   :

The docs say “When run in a supervisor, the director can be started using the hab start command.”

What does “When run in a supervisor” actually mean?

Ok, so, after some additional help on Slack, I learned that some initial setup is required :

# Make sure we have access to Director
sudo hab install core/hab-director > /dev/null 2>&1;
# Link Director into the Path of the host machine
sudo hab pkg binlink core/hab-director hab-director;

With that in place, I was able to get Director to start two packages with…

# Launch a Director supervised group as defined in ./myGroup.toml
sudo hab-director start -c myGroup.toml;

…where ./myGroup.toml looks like :

# Launch billmeyer.mongodb with --group tutorial and --org your0rg
# Additionally, pass in --permanent-peer to the start command
[cfg.services.billmeyer.mongodb.tutorial.your0rg]
start = "--permanent-peer --strategy at-once"

# Launch the tutorial into the same group and org. No config required
[cfg.services.your0rg.tutorial.tutorial.your0rg]

The next step was to try to change the configuration of the package your0rg/tutorial, using the command hab config apply.

I copied and modified the TOML file, to become ./myGroup_01.toml :

# Launch billmeyer.mongodb with --group tutorial and --org your0rg
# Additionally, pass in --permanent-peer to the start command
[cfg.services.billmeyer.mongodb.tutorial.your0rg]
start = "--permanent-peer --strategy at-once"

# Launch the tutorial into the same group and org. No config required
[cfg.services.your0rg.tutorial.tutorial.your0rg]
port=3033

I applied that new configuration with this command :

you@yourhost:~$ sudo hab config apply --peer 192.168.122.198 hab-director.default 1 myGroup_01.toml

However, I get this as a result :

» Applying configuration
↑ Applying configuration for hab-director.default into ring via [192.168.122.198:9634]
Joining peer: 192.168.122.198:9634
Failed to create a gossip client for 192.168.122.198:9634
Could not connect to any initial peers; attempt 1 of 10.
Joining peer: 192.168.122.198:9634
Failed to create a gossip client for 192.168.122.198:9634
Could not connect to any initial peers; attempt 2 of 10.
Joining peer: 192.168.122.198:9634
Failed to create a gossip client for 192.168.122.198:9634
Could not connect to any initial peers; attempt 3 of 10.

Obviously, I have specified something incorrectly, but how can I find out which one?

How would one go about incorporating configuring director to run multiple services and kicking it off within the plan/config/hooks of a package? So that when I hab start myapp, the plan/config/hooks within myapp start multiple services with directory?

Hmm. Well, I think the appropriate way of doing that (for now) might be to leverage systemd to call the director so its all preconfigured and can be launched with a simple service call?