Skip to content

Commit

Permalink
Removed rotatelogs setup in RESTDaemon
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ylee committed Apr 17, 2024
1 parent 1c955e2 commit a43ebca
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/python/WMCore/REST/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
up an appropriately configured CherryPy instance. Views are loaded dynamically
and can be turned on/off via configuration file.
If LOG-FILE does not contain `rotatelogs` and does not contain a date in
%Y%m%d format, a date will be added before the file extension.
If LOG-FILE does not contain a date in %Y%m%d format,
a date will be added before the file extension.
"""

from __future__ import print_function
Expand All @@ -17,6 +17,7 @@
from future import standard_library
standard_library.install_aliases()

from datetime import date
import errno
import logging
import os
Expand All @@ -40,6 +41,8 @@
from cherrypy.lib import profiler

# Tools is needed for CRABServer startup: it sets up the tools attributes
import WMCore.REST.Tools

from WMCore.Configuration import ConfigSection, loadConfigurationFile
from WMCore.WMLogging import getTimeRotatingLogger
from Utils.Utilities import lowerCmsHeaders
Expand Down Expand Up @@ -316,7 +319,8 @@ def __init__(self, config, statedir):
:arg str statedir: server state directory."""
RESTMain.__init__(self, config, statedir)
self.pidfile = "%s/%s.pid" % (self.statedir, self.appname)
self.logfile = ["rotatelogs", "%s/%s-%%Y%%m%%d.log" % (self.statedir, self.appname), "86400"]
todayStr = date.today().strftime("%Y%m%d")
self.logfile = f"{self.statedir}/{self.appname}-{todayStr}.log"

def daemon_pid(self):
"""Check if there is a daemon running, and if so return its pid.
Expand Down Expand Up @@ -574,18 +578,15 @@ def main():
running, pid = server.daemon_pid()
if running:
if not opts.quiet:
print("%s is %sRUNNING%s, PID %d"
% (app, COLOR_OK, COLOR_NORMAL, pid))
print(f"{app} is {COLOR_OK}RUNNING{COLOR_NORMAL}, PID {pid}")
sys.exit(0)
elif pid != None:
if not opts.quiet:
print("%s is %sNOT RUNNING%s, stale PID %d"
% (app, COLOR_WARN, COLOR_NORMAL, pid))
print(f"{app} is {COLOR_WARN}NOT RUNNING{COLOR_NORMAL}, PID {pid}")
sys.exit(2)
else:
if not opts.quiet:
print("%s is %sNOT RUNNING%s"
% (app, COLOR_WARN, COLOR_NORMAL))
print(f"{app} is {COLOR_WARN}NOT RUNNING{COLOR_NORMAL}")
sys.exit(1)

elif opts.kill:
Expand Down Expand Up @@ -620,13 +621,10 @@ def main():
# the logfile option to a list if it looks like a pipe request, i.e.
# starts with "|", such as "|rotatelogs foo/bar-%Y%m%d.log".
if opts.logfile:
if opts.logfile.startswith("|"):
server.logfile = re.split(r"\s+", opts.logfile[1:])
else:
server.logfile = opts.logfile
server.logfile = opts.logfile

# setup rotating log
getTimeRotatingLogger(None, server.logfile)
# setup rotating log
getTimeRotatingLogger(None, server.logfile)

# Actually start the daemon now.
server.start_daemon()

0 comments on commit a43ebca

Please sign in to comment.