|
|
@@ -43,16 +43,25 @@ static NSURL *serverRootWithHost(NSString *host) {
|
|
43
|
43
|
}
|
|
44
|
44
|
|
|
45
|
45
|
- (BOOL)isPackagerRunning:(NSString *)host {
|
|
46
|
|
- NSURL *url
|
|
47
|
|
- = [serverRootWithHost(host) URLByAppendingPathComponent:@"status"];
|
|
48
|
|
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
|
49
|
|
- NSURLResponse *response;
|
|
50
|
|
- NSData *data = [NSURLConnection sendSynchronousRequest:request
|
|
51
|
|
- returningResponse:&response
|
|
52
|
|
- error:NULL];
|
|
53
|
|
- NSString *status = [[NSString alloc] initWithData:data
|
|
54
|
|
- encoding:NSUTF8StringEncoding];
|
|
|
46
|
+ NSURL *url = [serverRootWithHost(host) URLByAppendingPathComponent:@"status"];
|
|
55
|
47
|
|
|
|
48
|
+ NSURLSession *session = [NSURLSession sharedSession];
|
|
|
49
|
+ NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
|
|
50
|
+ __block NSURLResponse *response;
|
|
|
51
|
+ __block NSData *data;
|
|
|
52
|
+
|
|
|
53
|
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
54
|
+ [[session dataTaskWithRequest:request
|
|
|
55
|
+ completionHandler:^(NSData *d,
|
|
|
56
|
+ NSURLResponse *res,
|
|
|
57
|
+ __unused NSError *err) {
|
|
|
58
|
+ data = d;
|
|
|
59
|
+ response = res;
|
|
|
60
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
61
|
+ }] resume];
|
|
|
62
|
+ dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
|
63
|
+
|
|
|
64
|
+ NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
56
|
65
|
return [status isEqualToString:@"packager-status:running"];
|
|
57
|
66
|
}
|
|
58
|
67
|
|