Add option to disable daemonization
We are double forking in the docker image and that seems to confuse docker because the process it started has exited. Fix this by adding a --no-daemon option to gerritbot then set that in the dockerfile. This should run gerritbot without any additional forking. Change-Id: I048115da5362a883360dcaf40860022ed5b63d47
This commit is contained in:
parent
a934f90f74
commit
1da055f809
@ -23,4 +23,4 @@ FROM opendevorg/python-base:3.7 as gerritbot
|
||||
COPY --from=builder /output/ /output
|
||||
RUN /output/install-from-bindep
|
||||
|
||||
CMD ["/usr/local/bin/gerritbot", "/etc/gerritbot/gerritbot.config"]
|
||||
CMD ["/usr/local/bin/gerritbot", "--no-daemon", "/etc/gerritbot/gerritbot.config"]
|
||||
|
@ -15,6 +15,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import daemon
|
||||
from ib3.auth import SASL
|
||||
@ -24,7 +25,6 @@ import json
|
||||
import logging.config
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import yaml
|
||||
@ -471,21 +471,26 @@ def _main(config):
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: %s CONFIGFILE" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('config_file', help='Path to the config file file')
|
||||
parser.add_argument('--no-daemon', dest='daemon', action='store_false',
|
||||
help='Option to disable daemonization')
|
||||
args = parser.parse_args()
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(sys.argv[1])
|
||||
config.read(args.config_file)
|
||||
|
||||
pid_path = ""
|
||||
if config.has_option('ircbot', 'pid'):
|
||||
pid_path = config.get('ircbot', 'pid')
|
||||
if args.daemon:
|
||||
pid_path = ""
|
||||
if config.has_option('ircbot', 'pid'):
|
||||
pid_path = config.get('ircbot', 'pid')
|
||||
else:
|
||||
pid_path = "/var/run/gerritbot/gerritbot.pid"
|
||||
|
||||
pid = pid_file_module.TimeoutPIDLockFile(pid_path, 10)
|
||||
with daemon.DaemonContext(pidfile=pid):
|
||||
_main(config)
|
||||
else:
|
||||
pid_path = "/var/run/gerritbot/gerritbot.pid"
|
||||
|
||||
pid = pid_file_module.TimeoutPIDLockFile(pid_path, 10)
|
||||
with daemon.DaemonContext(pidfile=pid):
|
||||
_main(config)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user