• Boxiang Sun's avatar
    monitor: Allow httpd to restart after the sever reboot from poweroff · ee35dc1c
    Boxiang Sun authored
    If a server reboots brutally, there will be a legacy httpd pid file stay
    in the file system, and the OS may reuse the PID that remains in that
    file, which will cause httpd service to fail to start even if there is
    no such httpd service is running.
    
    This commit implemented the following logic:
    0. If there is no existing PID file, then run the httpd service directly
    1. If the PID file exists and contains the PID used by another process,
    we delete the PID file, then restart the httpd service
    2. If the PID file exists and contains the PID used by another running
    httpd service, we allow the httpd report the "already running" error
    normally
    ee35dc1c
buildout.cfg 3.11 KB
[buildout]

extends =
  buildout.hash.cfg
  ../../component/apache/buildout.cfg
  ../../component/curl/buildout.cfg
  ../../component/dash/buildout.cfg
  ../../component/openssl/buildout.cfg
  ../../component/lxml-python/buildout.cfg
  ../../component/python-cryptography/buildout.cfg
  ../../component/randomsleep/buildout.cfg
  ../../stack/logrotate/buildout.cfg
  ../../stack/slapos.cfg

parts =
  slapos-cookbook
  monitor-eggs
  monitor2-template

[monitor-download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}

[monitor-eggs]
recipe = zc.recipe.egg
interpreter = monitor-pythonwitheggs
eggs =
  plone.recipe.command
  collective.recipe.template
  cns.recipe.symlink
  psutil
  PyRSS2Gen
  Jinja2
depends =
  ${slapos-toolbox:recipe}


# Monitor templates files
[monitor-httpd-conf]
<= monitor-download-base
filename = monitor-httpd.conf.in

[monitor-template-wrapper]
<= monitor-download-base
filename = wrapper.in

[monitor-conf]
<= monitor-download-base
filename = monitor.conf.in

[monitor-httpd-cors]
<= monitor-download-base
filename = httpd-cors.cfg.in

[template-monitor-httpd-wrapper]
<= monitor-download-base
filename = template-monitor-httpd-wrapper.sh.in
# End templates files

[monitor-template]
output = ${monitor2-template:output}

[monitor2-template]
recipe = slapos.recipe.template:jinja2
filename = template-monitor.cfg
url = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
output = ${buildout:directory}/template-monitor.cfg
context =
    key apache_location apache:location
    key template_logrotate_base template-logrotate-base:output
    key randomsleep randomsleep:output
    raw monitor_bin ${buildout:bin-directory}/monitor.bootstrap
    raw monitor_collect ${buildout:bin-directory}/monitor.collect
    raw monitor_statistic ${buildout:bin-directory}/monitor.statistic
    raw monitor_runpromise ${buildout:bin-directory}/monitor.runpromise
    raw monitor_genstatus ${buildout:bin-directory}/monitor.genstatus
    raw monitor_configwrite ${buildout:bin-directory}/monitor.configwrite
    raw monitor_conf_template ${monitor-conf:location}/${monitor-conf:filename}
    raw monitor_https_cors ${monitor-httpd-cors:location}/${monitor-httpd-cors:filename}
    raw curl_executable_location ${curl:location}/bin/curl
    raw dash_executable_location ${dash:location}/bin/dash
    raw dcron_executable_location ${dcron:location}/sbin/crond
    raw logrotate_executable_location ${logrotate:location}/usr/sbin/logrotate
    raw monitor_httpd_template ${monitor-httpd-conf:location}/${monitor-httpd-conf:filename}
    raw openssl_executable_location ${openssl:location}/bin/openssl
    raw python_executable ${buildout:executable}
    raw python_with_eggs ${buildout:bin-directory}/${monitor-eggs:interpreter}
    raw template_wrapper ${monitor-template-wrapper:location}/${monitor-template-wrapper:filename}
    raw template_monitor_httpd_wrapper  ${template-monitor-httpd-wrapper:location}/${template-monitor-httpd-wrapper:filename}
    raw check_disk_space ${buildout:bin-directory}/check-free-disk
    raw bin_directory ${buildout:directory}/bin

[versions]
cns.recipe.symlink = 0.2.3