Skip to content

Ch 04 - Solution for Mac users that want to run the epoll examples using docker #19

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

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

psalm842
Copy link
Contributor

Enable Running on Macs

Overview

Since Mac (and to a lesser extent Windows, though it has WSL) cannot work with epoll directly, Dockerfiles, Docker compose yml, and simple run scripts have been created so that users who have docker can run and test the ch04 examples on their system.

Details

A docker file has been created for delayserver as well and docker compose is used to run an epoll container and a delay server container and coordinate the network between them.

Some slight modification has been made to the epoll code to allow for an optional argument to be passed in which is the name of the host. When running the examples without docker and no arguments passed in (i.e. cargo run) "localhost" will be used by default. However when running docker containers epoll and delayserver are in separate containers, so epoll needs to transmit to the delayserver container (conveniently named "delayserver") instead of localhost. The dockerfiles supply the correct argument for the user.

Debian slim rust containers have been used as they are a convenient and fairly small container for these kinds of rust projects.

README.md's have been updated to note that it is now possible to pass an optional argument for the hostname to connect to, which will default to "localhost" if no argument is passed.

Further Comments

I've supplied this as a convenience for perhaps other mac users who may pick up this book. Hopefully it doesn't unnecessarily clutter up the code base.

psalm842 added 2 commits June 17, 2024 22:20
Since Mac (and to a lesser extent Windows, though it has WSL) cannot work with epoll directly, Dockerfiles,
Docker compose yml, and simple run scripts have been created so that users who have docker can run and test the ch04 examples on their
system.

A docker file has been created for delayserver as well and docker
compose is used to run an epoll container and a delay server
container and coordinate the network between them.

Some slight modification has been made to the epoll code to allow
for an optional argument to be passed in which is the name of the
host. When running the examples without docker both are running on
"localhost". However when running docker containers epoll and
delayserver are in separate containers, so epoll needs to transmit
to the delayserver container (conveniently named "delayserver") instead of localhost.

Debian slim rust containers have been used as they are a convenient
and fairly small container for these kinds of rust projects.

README.md's have been updated to note that it is now possible to pass an optional argument for the hostname to connect to, which will default to "localhost" if no argument is passed.
@psalm842
Copy link
Contributor Author

I've submitted this for your consideration, I'm working through the book and got to chapter 4 and wanted to run the examples on my mac. Feel free to close/reject this pull request if you judge this isn't ultimately helpful to the majority of your readers.

@cfsamson cfsamson changed the title Dockerfiles for Ch 04 Dockerfiles for Ch 04 - An alternative solution for Mac users that want to run the epoll examples Jun 18, 2024
@cfsamson cfsamson changed the title Dockerfiles for Ch 04 - An alternative solution for Mac users that want to run the epoll examples Dockerfiles for Ch 04 - Alternative for Mac users that want to run the epoll examples Jun 18, 2024
@cfsamson cfsamson changed the title Dockerfiles for Ch 04 - Alternative for Mac users that want to run the epoll examples Ch 04 - Solution for Mac users that want to run the epoll examples using docker Jun 18, 2024
@cfsamson
Copy link
Collaborator

This is great work! Thanks for the PR! I contemplated using docker for Mac users, but I decided on suggesting users to take the VM route instead. However, having this option as well is great and probably a lot easier for readers that already have docker installed.

I need some time to test and verify myself, and it's closing in on holidays here, so it might take some time to merge this depending on what time I can dedicate to this before summer. However, I'll change the PR title to make it easier to find for readers that take a closer look.

@kriskw1999
Copy link

@psalm842 I ended up too in using docker compose last day https://github.com/kriskw1999/rust-event-queue. I think too that for the already familiar docker users it is the easiest solution on Mac 🚀

@cfsamson
Copy link
Collaborator

cfsamson commented Jul 9, 2024

Sorry for the delay. This is just excellent @psalm842!!! Thanks for submitting. I've now gotten the chance to verify that everything works as it should on my mac as well! Great work!

@cfsamson cfsamson merged commit ae3f58b into PacktPublishing:main Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants