Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit accd3bd

Browse files
Merge pull request #29 from Unity-Technologies/bugfix/remove-cmd-prompt
Remove prompt package; simplify SIGINT handling
2 parents f228ea0 + 67577a6 commit accd3bd

File tree

3 files changed

+26
-180
lines changed

3 files changed

+26
-180
lines changed

main.js

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const { Server } = require('./lib');
77
const cluster = require('cluster');
88
const consts = require('./lib/constants');
99
const program = require('commander');
10-
const prompt = require('prompt');
1110
const ip = require('ip');
1211
const VERSION = require('./package.json').version;
1312
const fs = require('fs-extra');
@@ -126,7 +125,6 @@ Cache.init(cacheOpts)
126125
if(program.workers === 0) {
127126
server.start(errHandler).then(() => {
128127
helpers.log(consts.LOG_INFO, `Cache Server ready on port ${server.port}`);
129-
startPrompt();
130128
});
131129
}
132130

@@ -146,38 +144,9 @@ Cache.init(cacheOpts)
146144
process.exit(1);
147145
});
148146

149-
function startPrompt() {
150-
prompt.message = "";
151-
prompt.delimiter = "> ";
152-
prompt.start();
153-
154-
prompt.get(['command'], function(err, result) {
155-
if(err) {
156-
if(err.message === 'canceled') {
157-
result = { command: 'q' };
158-
}
159-
else {
160-
helpers.log(consts.LOG_ERR, err);
161-
server.stop();
162-
process.exit(1);
163-
}
164-
}
165-
166-
if(result) {
167-
switch(result.command) {
168-
case 'q':
169-
helpers.log(consts.LOG_INFO, "Shutting down ...");
170-
Cache.shutdown().then(() => {
171-
server.stop();
172-
process.exit(0);
173-
});
174-
break;
175-
}
176-
}
177-
178-
process.nextTick(startPrompt);
179-
});
180-
}
181-
182-
183-
147+
process.on('SIGINT', async () => {
148+
helpers.log(consts.LOG_INFO, "Shutting down...");
149+
await Cache.shutdown();
150+
await server.stop();
151+
process.exit(0);
152+
});

package-lock.json

Lines changed: 20 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"moment": "^2.20.1",
5353
"ora": "^1.4.0",
5454
"progress": "^2.0.0",
55-
"prompt": "^1.0.0",
5655
"uuid": "^3.1.0"
5756
},
5857
"eslintConfig": {

0 commit comments

Comments
 (0)