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

Steps to Integrate with existing app #65

Open
crslade opened this issue Aug 30, 2023 · 5 comments
Open

Steps to Integrate with existing app #65

crslade opened this issue Aug 30, 2023 · 5 comments

Comments

@crslade
Copy link

crslade commented Aug 30, 2023

I have an existing app. Is there some sort of checklist on what you have to do to integrate this into an existing app? I tried several times to integrate it with my app but haven't had success in getting it working.

The web container fails, saying that an existing server already exists. I have tried adding in a line in the entrypoint script to remove the /app/tmp/pids/server.pid file. Any suggestions on this?

Finally are there any other concerns I need to worry about running this on a M1 Mac? Do I need docker_sync to make it run better?

Thanks!

@nickjj
Copy link
Owner

nickjj commented Aug 30, 2023

Hi,

Everything should work with Apple Silicon. Modern versions of Docker Desktop with VirtioFS on macOS has good volume mount performance without docker_sync.

The README file has a list of changes vs a newly generated Rails at: https://github.com/nickjj/docker-rails-example#main-changes-vs-a-newly-generated-rails-app

Manually deleting the server.pid file is sometimes a step to perform if puma crashes hard without being able to clean itself up or you had an existing file prior to using Docker.

https://nickjanetakis.com/blog/a-guide-for-running-rails-in-docker covers a bunch of assorted topics.

@crslade
Copy link
Author

crslade commented Aug 30, 2023

Thanks. I was following along with your video and guide and didn't see the readme. That is very helpful.

Sorry if this shows my misunderstanding of docker, but the tmp directory (where the pid is stored) is in the .dockerignore file. So, the pid isn't coming from the host machine. It must be coming from the web container (or maybe the cable container?). How would I delete the pid file in the container, since it quits when puma can't start? I tried with the entrypoint script, and I tried tacking it onto the CMD in the dockerfile: CMD ["rm -f /app/tmp/pids/server.pid && rails s ...."]. Neither way worked.

Thanks again, this is a great guide.

@nickjj
Copy link
Owner

nickjj commented Aug 30, 2023

Under normal scenarios that pid file won't exist after puma stops. normally puma will delete it during its shutdown phase.

But deleting this file in an ENTRYPOINT script is not a bad idea, this will run before puma is started which will ensure no pid file exists before puma starts.

@crslade
Copy link
Author

crslade commented Aug 30, 2023

What do you think about this for stale pids? https://ieftimov.com/posts/docker-compose-stray-pids-rails-beyond/

@nickjj
Copy link
Owner

nickjj commented Aug 30, 2023

I'd prefer to have it in the entrypoint script since that gets executed before puma starts, it's basically the same as the CMD approach but a little cleaner. Alternatively configuring puma not to write a pid could be an option (I never looked into this to see if this is a good or bad idea).

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

No branches or pull requests

2 participants