aboutsummaryrefslogtreecommitdiffstats
path: root/Drop Serve
diff options
context:
space:
mode:
authorTeddy Wing2020-10-11 00:38:29 +0200
committerTeddy Wing2020-10-11 00:38:29 +0200
commit464d258b0cc29f889fa3e36d43022a0c6ec8a546 (patch)
treeaa77095bcc9f023ca15e74168932e12d5870e847 /Drop Serve
parentcc4879875a35042f1440c4445dbac9ea1b26589e (diff)
downloadDrop-Serve-464d258b0cc29f889fa3e36d43022a0c6ec8a546.tar.bz2
Server: Ensure the process is terminated before starting a new one
Just in case. Was getting a runtime exception occasionally and am still not entirely sure why. It happened in the `[Server stop]` call. Also check if the process is running before terminating it. Didn't read about whether we're required to do this, but it seemed logical.
Diffstat (limited to 'Drop Serve')
-rw-r--r--Drop Serve/Server.m7
1 files changed, 6 insertions, 1 deletions
diff --git a/Drop Serve/Server.m b/Drop Serve/Server.m
index 21da986..ad6146b 100644
--- a/Drop Serve/Server.m
+++ b/Drop Serve/Server.m
@@ -12,6 +12,8 @@
+ (void)serveAtPath:(NSString *)path
{
+ [self stop];
+
_process = [[NSTask alloc] init];
[_process setCurrentDirectoryPath:path];
[_process setLaunchPath:@"/usr/bin/python"];
@@ -27,7 +29,10 @@
+ (void)stop
{
- [_process terminate];
+ if ([_process isRunning]) {
+ [_process terminate];
+ }
+
[_process dealloc];
}