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

RPTDaemonTTL Config Directive #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markcarey
Copy link

Implemented new RPTDaemonTTL config directive. This commit does not change default behavior, but if user has specified a value, in seconds, for RPTDaemonTTL, then any run-periodic-tasks daemons will exit after this limit has been reached.

Primary usage is to avoid memory leak issues, works great when used in conjunction with daemontools supervise to auto-restart the rpt daemons.

…hange default behavior, but if user has specified a value, in seconds, for RPTDaemonTTL, then any run-periodic-tasks daemons will exit after this limit has been reached. Primary usage is to avoid memory leak issues, works great when used in conjunction with daemontools supervise to auto-restartthe rpt daemons.
@markcarey
Copy link
Author

Thank for the response, Tim. I thought about documentation but wasn't sure where/how to do so -- sorry I am not up to speed on the melody process. Thought about adding a couple of line to the pod docs for this module, but wasn't sure if there was a better place for it. The documentation for the MT config directive would be fairly short, something like: "Specifying a value for RPTDaemonTTL in your config file, in seconds, will effectively create a time limit on all run-periodic-tasks process running with the -daemon flag. For example 'RPTDaemonTTL 21600' would result in run-periodic-tasks daemons exiting after 6 hours. Used in conjunction with other tools to restart the daemons, this can help ensure that these process do not consume increasingly large amounts of server RAM."

WRT the daemontools usage, that it just one such 3rd-party tool that can be used in conjunction with this directive. I am sure there are others. Does it make sense to include this in melody docs? Here is a quick stab at it, FWIW:

Assuming that daemontools is already installed and running on the server, follow these steps for each run-periodic-tasks daemon process:

  1. Create a directory for the process. It can be anywhere on server, I name them rpt1, rpt2, etc and place them inside /mt/tools/, but others may prefer to create the directory outside the Melody directory structure (both works).
  2. Inside the directory, create a text file called 'run'. Daemontools must have permissions to execute this file, so permissions of at least 755 may be necessary.
  3. The contents of the 'run' file is a shell script that should start the daemon with your desired settings. For example:
    #!/bin/sh cd /full/path/cgi-bin/mt exec perl ./tools/run-periodic-tasks -verbose -daemon -leak >> /path/to/logs/mt_rpt1_log
    (side note: With the above syntax the daemon don't seem to log to the specified file, not sure why (thought the same command from the command line does write to the logs.)
  4. (Important) create a symbolic link to the new directory inside /service/. This will cause the daemontools supervise program to switch to the directory and execute the contents of the 'run' file, and then monitor it going forward. If the daemon stops running, daemontools will immediately restart it.

The combined usage of RPTDaemonTTL and daemontools can ensure that rpt daemons are restarted periodically, without the need for killing processes in the middle of some task or job.

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