docs: function initApp(defaults) {
  	if (!defaults) defaults = {}
  
  	// determine log
  	var jsonData = getHaraldOpsData(defaults)
  	var log = jsonData.log
  
  	// listen for errors
  	appshutdown.init({
  		log: console.log,
  		opsShutdown: jsonData.haraldopsShutdown,
  		signals: defaults.api && defaults.api.signals,
  		appName: jsonData.appName,
  		infoLog: !jsonData.noInfoLog ,
  		tmpFolder: jsonData.tmpFolder,
  	})
  	apperror.addErrorListener(emitter)
  	Error.stackTraceLimit = Infinity
  	log(emitter.id, 'is listening for errors')
  
  	var appData = appdata.initAppData(jsonData)
  
  	if (jsonData.haraldopsSendMail) emailer.setSendMail(jsonData.haraldopsSendMail)
  	else log(emitter.id, 'Warning: sendmail not available')
  
  	if (defaults.anomaly !== false) { // configure anomaly
  		/*
  		Control anomaly report emailing
  		defaults.anomaly.noEmail:
  		- string date: emailing disabled until after this date
  		- true: emailing disabled
  		- default: emailing enabled
  		*/
  		var doMailFlag = true
  		var setting = defaults.anomaly && defaults.anomaly.noEmail
  		if (setting != null) { // setting for email is present
  			if (typeof setting === 'string') {
  				var date = new Date(setting).getTime()
  				if (!isNaN(date)) { // unparseable date: email is on
  					var day = Math.floor((date - tzMs) / msPerDay) // day serial server timezone
  					day++ // enable mail the day after
  					doMailFlag = day * msPerDay + tzMs // timeval when email should be enabled again
  				}
  			} else doMailFlag = !setting // boolean value
  		}
  		if (doMailFlag !== true) anomaly.enableAnomalyMail(doMailFlag) // something else than enabled
  
  		var anomalySetting = haraldutil.shallowClone(defaults.anomaly)
  		if (!anomalySetting.app) anomalySetting.app = appData.appName
  		anomaly.initAnomaly(anomalySetting, appData.log)
  	}
  
  	serverwrapper.setEmitter(emitter)
  
  	// let haraldops register its routes
  	if (jsonData.haraldopsResponderFn && jsonData.haraldopsResponderUrl) {
  		var app = {get: serverwrapper.registerHandler}
  		jsonData.haraldopsResponderFn(app, jsonData.haraldopsResponderUrl)
  	}
  
  	// init api management
  	getrequire.init({apiOpts: defaults.api, appData: appData})
  	apionloader.doOnLoads(log)
  }