Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide way to source Bash helper methods to remote hosts #58

Closed
nickjer opened this issue Oct 10, 2017 · 0 comments
Closed

Provide way to source Bash helper methods to remote hosts #58

nickjer opened this issue Oct 10, 2017 · 0 comments
Assignees

Comments

@nickjer
Copy link
Contributor

nickjer commented Oct 10, 2017

The Bash helper methods:

  • create_passwd
  • find_port
  • ...

may need to be used on the host machines assigned to the batch job aside from the master node. One example is to start servers on the worker nodes using pbsdsh .... In order to start the servers we need to choose an available port to listen on using the find_port helper function.

One simple way to make the Bash helper methods more portable is to wrap them up in another Bash function such as...

source_helpers () {
  find_port () {
    # ...
  }
  create_passwd () {
    # ...
  }
  # ...
}
export -f source_helpers

by calling source_helpers in the main script, all of those functions are now available to it.

To make it available to pbsdsh scripts we could do...

pbsdsh bash -c "
  $(declare -f source_helpers)
  source_helpers

  ./start_server --port \$(find_port)
" &

The declare statement basically dumps the code for the helper functions in-place. Then we call that function to make the helpers available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant