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

Updates for crontabs #85

Closed
wants to merge 2 commits into from
Closed

Conversation

YodaDaCoda
Copy link
Contributor

  • Don't blow away existing crontabs during initCrontab() - allows for cron jobs to be created during BOOTSTRAP_HOOK
  • Added a simple script to restart the server

@cp-fabian-pittroff
Copy link
Member

Hey @YodaDaCoda, thanks for the PR and sorry for the late response.
Can you explain me the use case for the restart script? Wouldn't the docker stop/start or docker compose down/up command be sufficient for this?

@YodaDaCoda
Copy link
Contributor Author

Can you explain me the use case for the restart script?

I'm running a Public Resource World server & want to be able to restart the server hourly to reset containers etc back to their initial state. Doing so outside the container isn't quite as simple as using the bootstrap hook to overwrite the save files and setup a cron job.

Understandable if you feel the restart script isn't necessarily something that fits with your vision of this project, but it'd be great to at least include the other change.

@cp-fabian-pittroff
Copy link
Member

So you want to kill the container completely or would it be enough to just restart the enshrouded server process inside?

The initCrontab change, is no problem - I'll test it locally in the coming days.

@YodaDaCoda
Copy link
Contributor Author

Restarting the enshrouded process would be enough, but I didn't see a clear way of doing that cleanly (skill issue). I took inspiration from scripts/default/enshrouded-reset-roles

@cp-fabian-pittroff
Copy link
Member

Hey @YodaDaCoda, I just thought about your use case. You want to restart the enshrouded server periodically with a cronjob script.

Would it not be enough to just call supervisorctl restart enshrouded-server? So no really need of a dedicated script for that, or am I missing something?

I just tested, the enshrouded user, can also call supervisorctl commands.

@cp-fabian-pittroff
Copy link
Member

cp-fabian-pittroff commented Sep 19, 2024

And the suggested change for the crontab is unfortunately not possible. If you keep the crontab between restarts you basically add duplicates of the same cron.

enshrouded  | 2024-09-19 20:04:38.168 supervisord: enshrouded-bootstrap DEBUG - [24] - */30 * * * * supervisorctl start enshrouded-updater >/dev/null 2>&1
enshrouded  | 2024-09-19 20:04:38.168 supervisord: enshrouded-bootstrap */10 * * * * supervisorctl start enshrouded-backup >/dev/null 2>&1
enshrouded  | 2024-09-19 20:04:38.168 supervisord: enshrouded-bootstrap */30 * * * * supervisorctl start enshrouded-updater >/dev/null 2>&1
enshrouded  | 2024-09-19 20:04:38.168 supervisord: enshrouded-bootstrap */10 * * * * supervisorctl start enshrouded-backup >/dev/null 2>&1

But I see your problem there and have a solution for that. I can move the BOOTSTRAP_HOOK to after the crontab is initialized. So you can add and or modify as you wish.

  info "Running enshrouded-bootstrap"
  prepareEnshroudedAppFolders
  updateOrCreateEnshroudedServerConfig
  prepareSteamA2sPythonLibrary
  # old bootstrapHook position <---

  # no proton bootstrap needed

  initCrontab
  bootstrapHook # <--- moved down
  supervisorctl start enshrouded-updater
  info "Bootstrap complete"

Will this be sufficient? To keep it compatible I probably add another Hook BOOSTRAP_AFTER_CRON_HOOK or something.

@YodaDaCoda
Copy link
Contributor Author

Would it not be enough to just call supervisorctl restart enshrouded-server? So no really need of a dedicated script for that, or am I missing something?

Yeah that's probably enough. It wasn't clear to me how to achieve it so I thought a script with a name that indicated what it did would be helpful but happy to remove.

If you keep the crontab between restarts you basically add duplicates of the same cron.

You can deconflict this (and I do in my bootstrap hook script), but it's probably more effort than it's worth, particularly if...

I can move the BOOTSTRAP_HOOK to after the crontab is initialized. So you can add and or modify as you wish.

Yes please, this would be fantastic!

cp-fabian-pittroff added a commit that referenced this pull request Sep 27, 2024
refactor: moved bootstrap hook to after crontab is initialized (fixes #85)
@cp-fabian-pittroff
Copy link
Member

@YodaDaCoda, the changes are on the current develop build (e.g. dev-proton). Could you test it and see if the changes work for you?

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.

2 participants