Skip to content
Permalink
Browse files

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/…

  • Loading branch information...
cyrusdaboo committed Jul 13, 2016
1 parent b42927f commit c4498a250e8d130b76dfb89dc8d0de77a502f17a
@@ -168,6 +168,13 @@ init_build () {
use_openssl="false"
;;
esac;
else
case "$(uname -s)" in
Darwin)
# Needed to build OpenSSL 64-bit on OS X
export KERNEL_BITS=64
;;
esac
fi;
conditional_set requirements "${default_requirements}"

@@ -490,7 +497,7 @@ c_dependencies () {
if [ ${use_openssl} == "true" ]; then
ruler;

local min_ssl_version="9470095"; # OpenSSL 0.9.8zf
local min_ssl_version="268443791"; # OpenSSL 1.0.2h

local ssl_version="$(c_macro openssl/ssl.h OPENSSL_VERSION_NUMBER)";
if [ -z "${ssl_version}" ]; then ssl_version="0x0"; fi;
@@ -499,13 +506,13 @@ c_dependencies () {
if [ "${ssl_version}" -ge "${min_ssl_version}" ]; then
using_system "OpenSSL";
else
local v="0.9.8zh";
local v="1.0.2h";
local n="openssl";
local p="${n}-${v}";

# use 'config' instead of 'configure'; 'make' instead of 'jmake'.
# also pass 'shared' to config to build shared libs.
c_dependency -c "config" -s "3ff71636bea85a99f4d76a10d119c09bda0421e3" \
c_dependency -c "config" -s "577585f5f5d299c44dd3c993d3c0ac7a219e4949" \
-p "make depend" -b "make" \
"openssl" "${p}" \
"http://www.openssl.org/source/${p}.tar.gz" "shared";
@@ -245,6 +245,7 @@ def __init__(self, logEnabled, logPath, logRotateLength, logMaxFiles, logRotateO
self.logRotateLength = logRotateLength
self.logMaxFiles = logMaxFiles
self.logRotateOnStart = logRotateOnStart
self.name = "elms"


def setServiceParent(self, app):
@@ -280,7 +281,7 @@ class CalDAVService (ErrorLoggingMultiService):
# The ConnectionService is a MultiService which bundles all the connection
# services together for the purposes of being able to stop them and wait
# for all of their connections to close before shutting down.
connectionServiceName = "ConnectionService"
connectionServiceName = "cs"

def __init__(self, logObserver):
self.logObserver = logObserver # accesslog observer
@@ -292,6 +293,7 @@ def __init__(self, logObserver):
config.ErrorLogMaxRotatedFiles,
config.ErrorLogRotateOnStart,
)
self.name = "cds"


def privilegedStartService(self):
@@ -862,6 +864,11 @@ def location(frame):
frame=frame
)

if config.Manhole.Enabled:
namespace= dict({service.name: service})
for n, s in service.namedServices.iteritems():
namespace[n] = s
self._makeManhole(namespace=namespace, parent=service)
return service


@@ -898,6 +905,7 @@ def makeService_Slave(self, options):
result = self.requestProcessingService(options, store, logObserver)

if pool is not None:
pool.setName("db")
pool.setServiceParent(result)

if config.ControlSocket:
@@ -937,6 +945,7 @@ def queueMasterAvailable(connectionFromMaster):
controlClient = ControlSocketConnectingService(
endpointFactory, controlSocketClient
)
controlClient.setName("control")
controlClient.setServiceParent(result)

# Optionally set up push notifications
@@ -947,6 +956,7 @@ def queueMasterAvailable(connectionFromMaster):
pushSubService = ApplePushNotifierService.makeService(
config.Notifications.Services.APNS, store)
observers.append(pushSubService)
pushSubService.setName("APNS")
pushSubService.setServiceParent(result)
if config.Notifications.Services.AMP.Enabled:
pushSubService = AMPPushForwarder(controlSocketClient)
@@ -959,6 +969,7 @@ def queueMasterAvailable(connectionFromMaster):
mailRetriever = MailRetriever(
store, directory, config.Scheduling.iMIP.Receiving
)
mailRetriever.setName("MailRetriever")
mailRetriever.setServiceParent(result)
else:
mailRetriever = None
@@ -988,37 +999,6 @@ def decorateTransaction(txn):
txn._groupCacher = groupCacher

store.callWithNewTransactions(decorateTransaction)

# Optionally enable Manhole access
if config.Manhole.Enabled:
try:
from twisted.conch.manhole_tap import (
makeService as manholeMakeService
)
portString = "tcp:{:d}:interface=127.0.0.1".format(
config.Manhole.StartingPortNumber + int(config.LogID) + 1
)
manholeService = manholeMakeService({
"sshPort": None,
"telnetPort": portString,
"namespace": {
"config": config,
"service": result,
"store": store,
"directory": directory,
},
"passwd": config.Manhole.PasswordFilePath,
})
manholeService.setServiceParent(result)
# Using print(because logging isn't ready at this point)
print("Manhole access enabled:", portString)

except ImportError:
print(
"Manhole access could not enabled because "
"manhole_tap could not be imported"
)

return result


@@ -1181,10 +1161,12 @@ def updateFactory(configDict, reloading=False):
# 'SSL' tag on it, since that's the only time it's used.
contextFactory = None

ReportingHTTPService(
reportingService = ReportingHTTPService(
requestFactory, int(config.MetaFD), contextFactory,
usingSocketFile=config.SocketFiles.Enabled
).setServiceParent(connectionService)
usingSocketFile=config.SocketFiles.Enabled,
)
reportingService.setName("http-{}".format(int(config.MetaFD)))
reportingService.setServiceParent(connectionService)

else: # Not inheriting, therefore we open our own:
for bindAddress in self._allBindAddresses():
@@ -1211,6 +1193,8 @@ def updateFactory(configDict, reloading=False):
backlog=config.ListenBacklog,
inherit=False
)
httpsService.setName(
"https-{}:{}".format(bindAddress,int(port)))
httpsService.setServiceParent(connectionService)

for port in config.BindHTTPPorts:
@@ -1311,6 +1295,59 @@ def _spawnMemcached(self, monitor=None):
Popen(memcachedArgv)


def _makeManhole(self, namespace=None, parent=None):
try:
import inspect
import objgraph
except ImportError:
pass
try:
if 'inspect' in locals():
namespace['ins'] = inspect
if 'objgraph' in locals():
namespace['og'] = objgraph
from pprint import pprint
namespace.update({
'pp': pprint,
'cfg': config,
})
from twisted.conch.manhole_tap import (
makeService as manholeMakeService
)
portOffset = 0 if config.LogID == '' else int(config.LogID) + 1
portString = "tcp:{:d}:interface=127.0.0.1".format(
config.Manhole.StartingPortNumber + portOffset
)
manholeService = manholeMakeService({
"passwd": config.Manhole.PasswordFilePath,
"telnetPort":
portString if config.Manhole.UseSSH is False else None,
"sshPort":
portString if config.Manhole.UseSSH is True else None,
"sshKeyDir": config.DataRoot,
"sshKeyName": config.Manhole.sshKeyName,
"sshKeySize": config.Manhole.sshKeySize,
"namespace": namespace,
})
manholeService.setName("manhole")
if parent is not None:
manholeService.setServiceParent(parent)
# Using print(because logging isn't ready at this point)
print("Manhole access enabled:", portString)
except ImportError:
print(
"Manhole access could not enabled because "
"manhole_tap could not be imported."
)
import platform
if platform.system() == "Darwin":
if config.Manhole.UseSSH:
print(
"Set Manhole.UseSSH to false or rebuild CS with the "
"USE_OPENSSL environment variable set."
)


def makeService_Single(self, options):
"""
Create a service to be used in a single-process, stand-alone
@@ -1332,6 +1369,7 @@ def slaveSvcCreator(pool, store, logObserver, storageService):
config.Notifications.Services.APNS, store
)
observers.append(pushSubService)
pushSubService.setName("APNS")
pushSubService.setServiceParent(result)
if config.Notifications.Services.AMP.Enabled:
pushSubService = AMPPushMaster(
@@ -1362,6 +1400,7 @@ def slaveSvcCreator(pool, store, logObserver, storageService):
mailRetriever = MailRetriever(
store, directory, config.Scheduling.iMIP.Receiving
)
mailRetriever.setName("mailRetriever")
mailRetriever.setServiceParent(result)
else:
mailRetriever = None
@@ -1401,35 +1440,6 @@ def slaveSvcCreator(pool, store, logObserver, storageService):
else:
groupCacher = None

# Optionally enable Manhole access
if config.Manhole.Enabled:
try:
from twisted.conch.manhole_tap import (
makeService as manholeMakeService
)
portString = "tcp:{:d}:interface=127.0.0.1".format(
config.Manhole.StartingPortNumber
)
manholeService = manholeMakeService({
"sshPort": None,
"telnetPort": portString,
"namespace": {
"config": config,
"service": result,
"store": store,
"directory": directory,
},
"passwd": config.Manhole.PasswordFilePath,
})
manholeService.setServiceParent(result)
# Using print(because logging isn't ready at this point)
print("Manhole access enabled:", portString)
except ImportError:
print(
"Manhole access could not enabled because "
"manhole_tap could not be imported"
)

def decorateTransaction(txn):
txn._pushDistributor = pushDistributor
txn._rootResource = result.rootResource
@@ -1526,6 +1536,7 @@ def agentServiceCreator(pool, store, ignored, storageService):
config.ErrorLogMaxRotatedFiles,
config.ErrorLogRotateOnStart,
)
svc.setName("agent")
svc.setServiceParent(agentLoggingService)
return agentLoggingService

@@ -1582,6 +1593,7 @@ def subServiceFactory(connectionFactory, storageService):
dbtype=DatabaseType(dialect, paramstyle, dbfeatures),
maxConnections=config.MaxDBConnectionsPerPool
)
cp.setName("db")
cp.setServiceParent(ms)
store = storeFromConfigWithoutDPS(config, cp.connection)

@@ -1655,6 +1667,7 @@ def subServiceFactory(connectionFactory, storageService):
UpgradeReleaseLockStep(store)
)

pps.setName("pre")
pps.setServiceParent(ms)
return ms

@@ -1784,13 +1797,15 @@ def makeService_Combined(self, options):

monitor = DelayedStartupProcessMonitor()
s.processMonitor = monitor
monitor.setName("pm")
monitor.setServiceParent(s)

if config.MemoryLimiter.Enabled:
memoryLimiter = MemoryLimitService(
monitor, config.MemoryLimiter.Seconds,
config.MemoryLimiter.Bytes, config.MemoryLimiter.ResidentOnly
)
memoryLimiter.setName("ml")
memoryLimiter.setServiceParent(s)

# Maybe spawn memcached through a ProcessMonitor
@@ -1877,32 +1892,6 @@ def _openSocket(addr, port):
statsService.setName("tcp-stats")
statsService.setServiceParent(s)

# Optionally enable Manhole access
if config.Manhole.Enabled:
try:
from twisted.conch.manhole_tap import (
makeService as manholeMakeService
)
portString = "tcp:{:d}:interface=127.0.0.1".format(
config.Manhole.StartingPortNumber
)
manholeService = manholeMakeService({
"sshPort": None,
"telnetPort": portString,
"namespace": {
"config": config,
"service": s,
},
"passwd": config.Manhole.PasswordFilePath,
})
manholeService.setServiceParent(s)
# Using print(because logging isn't ready at this point)
print("Manhole access enabled:", portString)
except ImportError:
print(
"Manhole access could not enabled because "
"manhole_tap could not be imported"
)


# Finally, let's get the real show on the road. Create a service that
@@ -1944,11 +1933,13 @@ def spawnerSvcCreator(pool, store, ignored, storageService):
else:
dispenser = None
multi = MultiService()
multi.setName("multi")
pool.setServiceParent(multi)
spawner = SlaveSpawnerService(
self, monitor, dispenser, dispatcher, stats, options["config"],
inheritFDs=inheritFDs, inheritSSLFDs=inheritSSLFDs
)
spawner.setName("spawner")
spawner.setServiceParent(multi)
if config.UseMetaFD:
cl.setServiceParent(multi)
@@ -1961,6 +1952,7 @@ def spawnerSvcCreator(pool, store, ignored, storageService):
mailRetriever = MailRetriever(
store, directory, config.Scheduling.iMIP.Receiving
)
mailRetriever.setName("MailRetriever")
mailRetriever.setServiceParent(multi)
else:
mailRetriever = None
@@ -1993,6 +1985,7 @@ def decorateTransaction(txn):
ssvc = self.storageService(
spawnerSvcCreator, None, uid, gid
)
ssvc.setName("ssvc")
ssvc.setServiceParent(s)
return s

0 comments on commit c4498a2

Please sign in to comment.
You can’t perform that action at this time.