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

fix:fix the manual delete servers.pid file after restart container #365

Merged

Conversation

RayGuo-ergou
Copy link
Contributor

@RayGuo-ergou RayGuo-ergou commented Mar 13, 2022

Description

When we restart the doubtfire-api container, we need to delete the server.pid file in /tmp/pids manually. So I added a docker entrypoint srcipt to delete that file everytime before the container start if server.pid exist.

Type of change

Please delete options that are not relevant.

  • Bug fix

How Has This Been Tested?

I build the docker image in my local dev environment, then develop the project with that image. To test it, I firstly went to the container bash, make sure the server.pid file is in the right path then I restart the container several times and restart my PC to test if we still need to delete server.pid file manually. Also by monitoring the pids folder I can clearly see the file was removed then created when restart the container.

  • restart container
  • reboot PC

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if appropriate
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have created or extended unit tests to address my new additions
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@RayGuo-ergou RayGuo-ergou changed the title fix:fix the manual delete /tmp/pids/servers.pid file after restart co… fix:fix the manual delete servers.pid file after restart container Mar 13, 2022
Comment on lines 4 to 6
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be:

rm -f tmp/pids/server.pid

Copy link
Contributor Author

@RayGuo-ergou RayGuo-ergou Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jakerenzella for you suggestion, it makes more sence and I have push the change.

@jakerenzella
Copy link
Member

Nice! This annoys me all the time

@macite
Copy link
Member

macite commented Mar 14, 2022

@RayGuo-ergou I dont think the bundle exec is needed in the docker-entrypoint.sh as the CMD has this already. This will then also work if you want to run things outside of bundler.

@RayGuo-ergou
Copy link
Contributor Author

Hi @macite I have removed bundle exec in the docker-entrypoint.sh file.

@jakerenzella
Copy link
Member

Do we need the entry point file at all then?

@RayGuo-ergou
Copy link
Contributor Author

@jakerenzella Good point, maybe we can just add the rm -f command into CMD?

@jakerenzella
Copy link
Member

@jakerenzella Good point, maybe we can just add the rm -f command into CMD?

Yep 👍 keep it simple

@jakerenzella
Copy link
Member

@RayGuo-ergou this looks good but just need to double check that rm -f always returns a truthy value even if there's no file, otherwise the proceeding statements won't run

@jakerenzella
Copy link
Member

If not you can do rm -rf || command2 && command3 etc

@RayGuo-ergou
Copy link
Contributor Author

RayGuo-ergou commented Mar 14, 2022

@RayGuo-ergou this looks good but just need to double check that rm -f always returns a truthy value even if there's no file, otherwise the proceeding statements won't run

I tested to start the container when the server,pid file is deleted and it's running okay. Is that what you mean, sorry I am not very sure.

ls can be excuted
image

@jakerenzella
Copy link
Member

@RayGuo-ergou this looks good but just need to double check that rm -f always returns a truthy value even if there's no file, otherwise the proceeding statements won't run

I tested to start the container when the server,pid file is deleted and it's running okay. Is that what you mean, sorry I am not very sure.

ls can be excuted image

This looks all good then :)

@jakerenzella jakerenzella merged commit c44915a into doubtfire-lms:development Mar 14, 2022
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

Successfully merging this pull request may close these issues.

3 participants