Commit 45140cde authored by Viktor Horvath's avatar Viktor Horvath

Apache is running! but Mioga not yet.

parent 4d15f8ba
......@@ -29,6 +29,7 @@ import os
import pprint
import re
import shutil
import signal
import stat
import subprocess
......@@ -46,6 +47,12 @@ class Recipe(GenericBaseRecipe):
os.remove(filepath)
def install(self):
self.instantiate(True)
def update(self):
self.instantiate(False)
def instantiate(self, isNewInstall):
print "This is the Mioga recipe"
print "Looking for compile folder:"
print self.options['mioga_compile_dir']
......@@ -106,8 +113,80 @@ class Recipe(GenericBaseRecipe):
env=environ, shell=True)
cmd.communicate()
# Apache configuration!
# Take the files that Mioga has prepared, and wrap some standard configuration around it.
# TODO: can't we squeeze this somehow into the generic apacheperl recipe?
apache_config_mioga = '''
LoadModule alias_module modules/mod_alias.so
LoadModule apreq_module modules/mod_apreq2.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule headers_module modules/mod_headers.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule perl_module modules/mod_perl.so
# Basic server configuration
# TODO: how to listen to standard port 80 when we are not root?
PidFile REPL_PID
Listen [REPL_IPV6HOST]:REPL_IPV6PORT
# Listen [REPL_IPV6]:443 # what about mod_ssl and all that stuff?
# ServerAdmin someone@email
# Log configuration
ErrorLog REPL_ERRORLOG
LogLevel debug
CustomLog REPL_ACCESSLOG common
DocumentRoot REPL_DOCROOT
'''
apache_config_mioga = (apache_config_mioga
.replace('REPL_PID', self.options['pid_file'])
.replace('REPL_IPV6HOST', self.options['public_ipv6'])
.replace('REPL_IPV6PORT', self.options['public_ipv6_port'])
.replace('REPL_ERRORLOG', self.options['error_log'])
.replace('REPL_ACCESSLOG', self.options['access_log'])
.replace('REPL_DOCROOT', self.options['htdocs']) )
mioga_prepared_apache_config_dir = os.path.join(mioga_base, 'conf', 'apache')
for filepath in os.listdir(mioga_prepared_apache_config_dir):
apache_config_mioga += ("# Read in from "+filepath+"\n" +
open(os.path.join(mioga_prepared_apache_config_dir, filepath)).read() + "\n" )
# Internal DAV only accepts its own IPv6 address
# TODO: check with what sender address we really arrive at the DAV locations.
apache_config_mioga = re.sub(
'Allow from localhost',
'# Allow from localhost',
apache_config_mioga)
path_list = []
open(self.options['httpd_conf'], 'w').write(apache_config_mioga)
# TODO: if that all works fine, put it into a proper template
# httpd_conf = self.createFile(self.options['httpd_conf'],
# self.substituteTemplate(self.getTemplateFilename('apache.in'),
# apache_config)
# )
path_list.append(os.path.abspath(self.options['httpd_conf']))
wrapper = self.createPythonScript(self.options['wrapper'],
'slapos.recipe.librecipe.execute.execute',
[self.options['httpd_binary'], '-f', self.options['httpd_conf'],
'-DFOREGROUND']
)
path_list.append(wrapper)
if os.path.exists(self.options['pid_file']):
# Reload apache configuration
with open(self.options['pid_file']) as pid_file:
pid = int(pid_file.read().strip(), 10)
try:
os.kill(pid, signal.SIGUSR1) # Graceful restart
except OSError:
pass
os.chdir(former_directory)
print "Mioga instantiate.py::install finished!"
return path_list
# Copied verbatim from mioga-hooks.py - how to reuse code?
......
[buildout]
parts =
postgres-urlparse
apacheperl-promise
publish-connection-information
# apacheperl-promise
mioga-instance
publish-connection-information
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
......@@ -22,22 +22,6 @@ services = $${rootdirectory:etc}/run
promises = $${rootdirectory:etc}/promise
htdocs = $${rootdirectory:srv}/htdocs
[apacheperl-instance]
recipe = slapos.cookbook:apacheperl
ip = $${slap-network-information:global-ipv6}
port = 8080
httpd-binary = ${apache-2.2:location}/bin/httpd
# XXX TODO: Wait for the iso to be uploaded (execute_wait)
path = $${basedirectory:services}/apacheperl
htdocs = $${basedirectory:htdocs}
httpd-conf = $${rootdirectory:etc}/httpd.conf
pid-file = $${basedirectory:services}/apache.pid
lock-file = $${basedirectory:services}/apache.lock
wrapper = $${basedirectory:services}/httpd_wrapper
# source = ${buildout:parts-directory}/${:_buildout_section_name_}
error-log = $${rootdirectory:log}/error.log
access-log = $${rootdirectory:log}/access.log
[apacheperl-promise]
recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/httpd_promise
......@@ -46,7 +30,7 @@ port = $${apacheperl-instance:port}
[publish-connection-information]
recipe = slapos.cookbook:publish
apacheperl_url = http://[$${apacheperl-instance:ip}]:$${apacheperl-instance:port}
apacheperl_url = http://[$${slap-network-information:global-ipv6}]:$${mioga-instance:public_ipv6_port}
# Request Postgres instance and parse its URL
[request-postgres]
......@@ -84,3 +68,15 @@ db_port = $${postgres-urlparse:port}
db_dbname = $${postgres-urlparse:path}
db_username = $${postgres-urlparse:username}
db_password = $${postgres-urlparse:password}
public_ipv6 = $${slap-network-information:global-ipv6}
public_ipv6_port = 8080
private_ipv4 = $${slap-network-information:local-ipv4}
httpd_binary = ${apache-2.2:location}/bin/httpd
path = $${basedirectory:services}/apacheperl
htdocs = $${basedirectory:htdocs}
httpd_conf = $${rootdirectory:etc}/httpd.conf
pid_file = $${basedirectory:services}/apache.pid
lock_file = $${basedirectory:services}/apache.lock
wrapper = $${basedirectory:services}/httpd_wrapper
error_log = $${rootdirectory:log}/error.log
access_log = $${rootdirectory:log}/access.log
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment