@@ -13,6 +13,7 @@ let hostname = '127.0.0.1';
13
13
function setHostname ( newHostname ) {
14
14
hostname = newHostname ;
15
15
}
16
+
16
17
module . exports . setHostname = setHostname ;
17
18
18
19
/**
@@ -43,14 +44,16 @@ async function followLog(rooms, logConsole, statusUpdater, restrictToRoom) {
43
44
44
45
await api . auth ( ) ;
45
46
46
- api . socket . connect ( ) ;
47
+ await api . socket . connect ( ) ;
47
48
api . socket . on ( 'connected' , ( ) => { } ) ;
48
49
api . socket . on ( 'auth' , ( event ) => { } ) ;
49
- api . socket . subscribe ( 'console' , logConsole ( room ) ) ;
50
- api . socket . subscribe ( 'room:' + room , statusUpdater ) ;
50
+ await api . socket . subscribe ( 'console' , logConsole ( room ) ) ;
51
+ await api . socket . subscribe ( 'room:' + room , statusUpdater ) ;
51
52
}
52
- return new Promise ( ( ) => { } ) ;
53
+ return new Promise ( ( ) => {
54
+ } ) ;
53
55
}
56
+
54
57
module . exports . followLog = followLog ;
55
58
56
59
/**
@@ -92,6 +95,7 @@ module.exports.setPassword = setPassword;
92
95
function sleep ( seconds ) {
93
96
return new Promise ( ( resolve ) => setTimeout ( resolve , seconds * 1000 ) ) ;
94
97
}
98
+
95
99
module . exports . sleep = sleep ;
96
100
97
101
async function initServer ( ) {
@@ -107,6 +111,15 @@ async function initServer() {
107
111
const configFilename = path . resolve ( dir , '.screepsrc' ) ;
108
112
let config = fs . readFileSync ( configFilename , { encoding : 'utf8' } ) ;
109
113
config = config . replace ( / { { STEAM_ K E Y } } / , process . env . STEAM_API_KEY ) ;
114
+ config += '\n\n' ;
115
+ if ( process . env . MONGO_HOST ) {
116
+ config += '[mongo]\n' ;
117
+ config += `host = ${ process . env . MONGO_HOST } \n\n` ;
118
+ }
119
+ if ( process . env . REDIS_HOST ) {
120
+ config += '[redis]\n' ;
121
+ config += `host = ${ process . env . REDIS_HOST } \n\n` ;
122
+ }
110
123
fs . writeFileSync ( configFilename , config ) ;
111
124
fs . chmodSync ( path . resolve ( dir , 'node_modules/.hooks/install' ) , '755' ) ;
112
125
fs . chmodSync ( path . resolve ( dir , 'node_modules/.hooks/uninstall' ) , '755' ) ;
@@ -127,6 +140,7 @@ async function initServer() {
127
140
console . log ( e ) ;
128
141
}
129
142
}
143
+
130
144
module . exports . initServer = initServer ;
131
145
132
146
/**
@@ -139,13 +153,14 @@ async function startServer() {
139
153
process . chdir ( dir ) ;
140
154
return lib . start ( { } , process . stdout ) ;
141
155
}
156
+
142
157
module . exports . startServer = startServer ;
143
158
144
159
/**
145
160
* logs event
146
161
*
147
162
* @param {string } room
148
- * @return {void }
163
+ * @return {function }
149
164
*/
150
165
const logConsole = function ( room ) {
151
166
return ( event ) => {
0 commit comments