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

feat(cron): add toggle-cronjobs command #4508

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

MicLieg
Copy link
Contributor

@MicLieg MicLieg commented Feb 25, 2024

Description

This pull request introduces a new command: ./gameserver toggle-cronjobs

This command simplifies cronjob management for LinuxGSM users and auto deployment scripts, making it easier to ensure that server monitoring, updates, and restarts are performed automatically according to the specified schedules.

The toggle-cronjobs command operates by identifying whether cronjobs, using the specified LinuxGSM commands, exist within the system's crontab and wehter these were aded by LinuxGSM:

  1. If there is no cronjob using the specified LinuxGSM command, a new cronjob will be created for the specified command.
  2. If there is a cronjob using the specified LinuxGSM command that was added by LinuxGSM, the cronjob will be removed.
  3. If there is a cronjob using the specified LinuxGSM command that was NOT added by LinuxGSM, the specified LinuxGSM command will be skipped and no cronjob will be added or removed.

I've chosen to include similar cronjobs as the Example cronjobs:

fn_toggle_cronjob "monitor" "*/5 * * * *" # Every 5 minutes
fn_toggle_cronjob "update" "*/30 * * * *" # Every 30 minutes
fn_toggle_cronjob "update-lgsm" "0 0 * * *" # Daily at midnight
fn_toggle_cronjob "restart" "30 4 * * *" # Daily at 4:30am

Currently the output of all LinuxGSM managed cronjobs including all erros will be sent to /dev/null. It might be woth saving the logs to LinuxGSM's log dir.

Fixes #4329

Type of change

  • Bug fix (a change which fixes an issue).
  • New feature (a change which adds functionality).
  • New Server (new server added).
  • Refactor (restructures existing code).
  • Comment update (typo, spelling, explanation, examples, etc).

Checklist

PR will not be merged until all steps are complete.

  • This pull request links to an issue.
  • This pull request uses the develop branch as its base.
  • This pull request subject follows the Conventional Commits standard.
  • This code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have checked that this code is commented where required.
  • I have provided a detailed enough description of this PR.
  • I have checked if documentation needs updating.
    • I will add documentation once I get feedback on whether this PR will be merged.

Documentation

If documentation does need updating either update it by creating a PR (preferred) or request a documentation update.

Thank you for your Pull Request!

@dgibbs64
Copy link
Member

Very nice PR. Will take me a little time to review and test properly. But overall I like it 👍🏻

@MicLieg MicLieg force-pushed the feature/toggle-cronjobs-command branch from fe00562 to 0723db9 Compare March 10, 2024 10:40
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.

None yet

2 participants