Skip to content
Browse files

Create "Listener" app target/scheme

A slight variant of the EmptyApp that listens on all network interfaces at the regular port 5984. This allows another host to talk to the database to test it.

Change-Id: I9cfec4d9eb0d23a81a9ef221b5261f742fecf099
Reviewed-on: http://review.couchbase.org/9214
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
  • Loading branch information...
1 parent 03dedb1 commit 95d6844851fbe895afe2323ed865fbb412e823c1 @snej snej committed Aug 24, 2011
View
109 EmptyApp/Empty App.xcodeproj/project.pbxproj
@@ -7,6 +7,15 @@
objects = {
/* Begin PBXBuildFile section */
+ 273112D8140559B30072C622 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A3ACF513C78BD9008CE9F0 /* main.m */; };
+ 273112D9140559B30072C622 /* EmptyAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A3ACF913C78BD9008CE9F0 /* EmptyAppDelegate.m */; };
+ 273112DB140559B30072C622 /* libstdc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3AD1C13C78DAC008CE9F0 /* libstdc++.dylib */; };
+ 273112DC140559B30072C622 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3ACE913C78BD9008CE9F0 /* UIKit.framework */; };
+ 273112DD140559B30072C622 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3ACEB13C78BD9008CE9F0 /* Foundation.framework */; };
+ 273112DE140559B30072C622 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3ACED13C78BD9008CE9F0 /* CoreGraphics.framework */; };
+ 273112DF140559B30072C622 /* Couchbase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3AD1A13C78C32008CE9F0 /* Couchbase.framework */; };
+ 273112E1140559B30072C622 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 27A3ACF213C78BD9008CE9F0 /* InfoPlist.strings */; };
+ 273112EB14055A410072C622 /* app.ini in Resources */ = {isa = PBXBuildFile; fileRef = 273112EA14055A410072C622 /* app.ini */; };
27A3ACEA13C78BD9008CE9F0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3ACE913C78BD9008CE9F0 /* UIKit.framework */; };
27A3ACEC13C78BD9008CE9F0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3ACEB13C78BD9008CE9F0 /* Foundation.framework */; };
27A3ACEE13C78BD9008CE9F0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27A3ACED13C78BD9008CE9F0 /* CoreGraphics.framework */; };
@@ -35,6 +44,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
+ 273112E6140559B30072C622 /* Listener.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Listener.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 273112EA14055A410072C622 /* app.ini */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = app.ini; sourceTree = "<group>"; };
27A3ACE513C78BD9008CE9F0 /* Empty App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Empty App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
27A3ACE913C78BD9008CE9F0 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
27A3ACEB13C78BD9008CE9F0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -56,6 +67,18 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
+ 273112DA140559B30072C622 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 273112DB140559B30072C622 /* libstdc++.dylib in Frameworks */,
+ 273112DC140559B30072C622 /* UIKit.framework in Frameworks */,
+ 273112DD140559B30072C622 /* Foundation.framework in Frameworks */,
+ 273112DE140559B30072C622 /* CoreGraphics.framework in Frameworks */,
+ 273112DF140559B30072C622 /* Couchbase.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
27A3ACE213C78BD9008CE9F0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -97,6 +120,7 @@
children = (
27A3ACE513C78BD9008CE9F0 /* Empty App.app */,
27A3AD0013C78BD9008CE9F0 /* Empty AppTests.octest */,
+ 273112E6140559B30072C622 /* Listener.app */,
);
name = Products;
sourceTree = "<group>";
@@ -131,6 +155,7 @@
27A3ACF213C78BD9008CE9F0 /* InfoPlist.strings */,
27A3ACF513C78BD9008CE9F0 /* main.m */,
27A3ACF713C78BD9008CE9F0 /* Empty App-Prefix.pch */,
+ 273112EA14055A410072C622 /* app.ini */,
);
name = "Supporting Files";
sourceTree = "<group>";
@@ -157,6 +182,24 @@
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
+ 273112D6140559B30072C622 /* Listener */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 273112E3140559B30072C622 /* Build configuration list for PBXNativeTarget "Listener" */;
+ buildPhases = (
+ 273112D7140559B30072C622 /* Sources */,
+ 273112DA140559B30072C622 /* Frameworks */,
+ 273112E0140559B30072C622 /* Resources */,
+ 273112E2140559B30072C622 /* Copy CouchbaseResources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = Listener;
+ productName = "Couchbase Empty App";
+ productReference = 273112E6140559B30072C622 /* Listener.app */;
+ productType = "com.apple.product-type.application";
+ };
27A3ACE413C78BD9008CE9F0 /* Empty App */ = {
isa = PBXNativeTarget;
buildConfigurationList = 27A3AD1413C78BD9008CE9F0 /* Build configuration list for PBXNativeTarget "Empty App" */;
@@ -217,11 +260,21 @@
targets = (
27A3ACE413C78BD9008CE9F0 /* Empty App */,
27A3ACFF13C78BD9008CE9F0 /* Empty AppTests */,
+ 273112D6140559B30072C622 /* Listener */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
+ 273112E0140559B30072C622 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 273112E1140559B30072C622 /* InfoPlist.strings in Resources */,
+ 273112EB14055A410072C622 /* app.ini in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
27A3ACE313C78BD9008CE9F0 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -242,6 +295,21 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
+ 273112E2140559B30072C622 /* Copy CouchbaseResources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Copy CouchbaseResources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# The 'CouchbaseResources' subfolder of the framework contains Erlang code and other resources needed at runtime. Copy it into the app bundle:\nrm -rf \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CouchbaseResources\"\nrsync -a \"${TARGET_BUILD_DIR}/../${CONFIGURATION}-universal/Couchbase.framework/CouchbaseResources\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}\"";
+ showEnvVarsInLog = 0;
+ };
27A3ACFE13C78BD9008CE9F0 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -273,6 +341,15 @@
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
+ 273112D7140559B30072C622 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 273112D8140559B30072C622 /* main.m in Sources */,
+ 273112D9140559B30072C622 /* EmptyAppDelegate.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
27A3ACE113C78BD9008CE9F0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -320,6 +397,29 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
+ 273112E4140559B30072C622 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ INFOPLIST_FILE = "Source/Empty App-Info.plist";
+ PRODUCT_NAME = Listener;
+ STRIP_INSTALLED_PRODUCT = NO;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 273112E5140559B30072C622 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DEPLOYMENT_POSTPROCESSING = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ INFOPLIST_FILE = "Source/Empty App-Info.plist";
+ PRODUCT_NAME = Listener;
+ STRIP_INSTALLED_PRODUCT = YES;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
27A3AD1213C78BD9008CE9F0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -435,6 +535,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
+ 273112E3140559B30072C622 /* Build configuration list for PBXNativeTarget "Listener" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 273112E4140559B30072C622 /* Debug */,
+ 273112E5140559B30072C622 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
27A3ACDF13C78BD9008CE9F0 /* Build configuration list for PBXProject "Empty App" */ = {
isa = XCConfigurationList;
buildConfigurations = (
View
84 EmptyApp/Empty App.xcodeproj/xcshareddata/xcschemes/Listener.xcscheme
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "273112D6140559B30072C622"
+ BuildableName = "Listener.app"
+ BlueprintName = "Listener"
+ ReferencedContainer = "container:Empty App.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "273112D6140559B30072C622"
+ BuildableName = "Listener.app"
+ BlueprintName = "Listener"
+ ReferencedContainer = "container:Empty App.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "273112D6140559B30072C622"
+ BuildableName = "Listener.app"
+ BlueprintName = "Listener"
+ ReferencedContainer = "container:Empty App.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "273112D6140559B30072C622"
+ BuildableName = "Listener.app"
+ BlueprintName = "Listener"
+ ReferencedContainer = "container:Empty App.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
View
1 EmptyApp/Source/EmptyAppDelegate.h
@@ -15,4 +15,5 @@
@property (retain, nonatomic) NSURL* serverURL;
+@property (readonly) NSString* localIPAddress;
@end
View
41 EmptyApp/Source/EmptyAppDelegate.m
@@ -7,6 +7,9 @@
//
#import "EmptyAppDelegate.h"
+#import <ifaddrs.h>
+#import <netinet/in.h>
+#import <net/if.h>
@implementation EmptyAppDelegate
@@ -30,6 +33,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Initialize CouchDB:
CouchbaseMobile* cb = [[CouchbaseMobile alloc] init];
cb.delegate = self;
+ NSString* iniPath = [[NSBundle mainBundle] pathForResource: @"app" ofType: @"ini"];
+ if (iniPath) {
+ NSLog(@"Registering custom .ini file %@", iniPath);
+ cb.iniFilePath = iniPath;
+ }
NSAssert([cb start], @"Couchbase couldn't start! Error = %@", cb.error);
sCouchbase = cb;
return YES;
@@ -87,16 +95,12 @@ - (void)send: (NSString*)method toPath: (NSString*)relativePath body: (NSString*
-(void)couchbaseMobile:(CouchbaseMobile*)couchbase didStart:(NSURL*)serverURL {
NSLog(@"CouchDB is Ready, go!");
+ NSLog(@"My local IP address is %@", self.localIPAddress);
self.serverURL = serverURL;
if (!sUnitTesting) {
[self send: @"GET" toPath: @"/" body: nil];
- [self send: @"PUT" toPath: @"/testdb" body: nil];
- [self send: @"GET" toPath: @"/testdb" body: nil];
- [self send: @"POST" toPath: @"/testdb/" body: @"{\"txt\":\"foobar\"}"];
- [self send: @"PUT" toPath: @"/testdb/doc1" body: @"{\"txt\":\"O HAI\"}"];
- [self send: @"GET" toPath: @"/testdb/doc1" body: nil];
- NSLog(@"Everything works!");
+ NSLog(@"Couchbase is alive! Run the unit tests to be sure everything works.");
}
}
@@ -106,4 +110,29 @@ -(void)couchbaseMobile:(CouchbaseMobile*)couchbase failedToStart:(NSError*)error
}
+- (NSString*)localIPAddress {
+ // getifaddrs returns a linked list of interface entries;
+ // find the first active non-loopback interface with IPv4:
+ UInt32 address = 0;
+ struct ifaddrs *interfaces;
+ if( getifaddrs(&interfaces) == 0 ) {
+ struct ifaddrs *interface;
+ for( interface=interfaces; interface; interface=interface->ifa_next ) {
+ if( (interface->ifa_flags & IFF_UP) && ! (interface->ifa_flags & IFF_LOOPBACK) ) {
+ const struct sockaddr_in *addr = (const struct sockaddr_in*) interface->ifa_addr;
+ if( addr && addr->sin_family==AF_INET ) {
+ address = addr->sin_addr.s_addr;
+ break;
+ }
+ }
+ }
+ freeifaddrs(interfaces);
+ }
+
+ const UInt8* b = (const UInt8*)&address;
+ return [NSString stringWithFormat: @"%u.%u.%u.%u",
+ (unsigned)b[0],(unsigned)b[1],(unsigned)b[2],(unsigned)b[3]];
+}
+
+
@end
View
5 EmptyApp/Source/app.ini
@@ -0,0 +1,5 @@
+; Custom initialization for the Listener app.
+
+[httpd]
+bind_address = 0.0.0.0 ; listen on all interfaces
+port = 5984 ; standard CouchDB port

0 comments on commit 95d6844

Please sign in to comment.
Something went wrong with that request. Please try again.