@@ -14,21 +14,20 @@ This is useful for:
14
14
- development of cocalc from inside of a CoCalc project
15
15
- non-collaborative use of cocalc on your own
16
16
laptop, e.g., when you're on an airplane.
17
-
18
-
17
+
18
+
19
19
DEVELOPMENT:
20
20
21
21
22
22
~/cocalc/src/packages/server/projects/control$ COCALC_MODE='single-user' node
23
23
Welcome to Node.js v20.19.1.
24
24
Type ".help" for more information.
25
- > a = require('@cocalc/server/projects/control');
25
+ > a = require('@cocalc/server/projects/control');
26
26
> p = a.getProject('8a840733-93b6-415c-83d4-7e5712a6266b')
27
27
> await p.start()
28
28
*/
29
29
30
- import { kill } from "process" ;
31
-
30
+ import { kill } from "node:process" ;
32
31
import getLogger from "@cocalc/backend/logger" ;
33
32
import {
34
33
BaseProject ,
@@ -153,16 +152,26 @@ class Project extends BaseProject {
153
152
try {
154
153
this . stateChanging = { state : "stopping" } ;
155
154
await this . saveStateToDatabase ( this . stateChanging ) ;
156
- try {
157
- const pid = await getProjectPID ( this . HOME ) ;
158
- logger . debug ( `stop: sending kill -${ pid } ` ) ;
159
- kill ( - pid ) ;
160
- } catch ( err ) {
161
- // expected exception if no pid
162
- logger . debug ( `stop: kill err ${ err } ` ) ;
163
- }
155
+ const pid = await getProjectPID ( this . HOME ) ;
156
+ const killProject = ( ) => {
157
+ try {
158
+ logger . debug ( `stop: sending kill -${ pid } ` ) ;
159
+ kill ( - pid , "SIGKILL" ) ;
160
+ } catch ( err ) {
161
+ // expected exception if no pid
162
+ logger . debug ( `stop: kill err ${ err } ` ) ;
163
+ }
164
+ } ;
165
+ killProject ( ) ;
164
166
await this . wait ( {
165
- until : async ( ) => ! ( await isProjectRunning ( this . HOME ) ) ,
167
+ until : async ( ) => {
168
+ if ( await isProjectRunning ( this . HOME ) ) {
169
+ killProject ( ) ;
170
+ return false ;
171
+ } else {
172
+ return true ;
173
+ }
174
+ } ,
166
175
maxTime : MAX_STOP_TIME_MS ,
167
176
} ) ;
168
177
await deleteProjectSecretToken ( this . project_id ) ;
0 commit comments