Skip to content

Commit

Permalink
Issue #4: createStone.solo and deleteStone.solo pretty solid
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehenrich committed May 31, 2023
1 parent c463cf2 commit 3f3006f
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 39 deletions.
6 changes: 4 additions & 2 deletions bin/deleteStone.solo
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ RwLoadSpecificationV2 {
]
%
doit
| registryClass stonesRegistry toneName stoneSpec |
| registryClass stonesRegistry stoneName stoneSpec |
self preDoitSpecLoad: [:spec |
spec projectName = 'GsCommands'
ifTrue: [ spec projectsHome: '$GEMSTONE/examples/GsCommands/projectsHome' ]
Expand All @@ -78,6 +78,8 @@ doit
self positionalArgs size ~= 1
ifTrue: [ self error: 'Expected a positional argument: <stone-name>' ].
stoneName := self positionalArgs at: 1.
stonesRegistry destroyStoneNamed: stoneName.
stoneSpec := stonesRegistry stoneNamed: stoneName.
System gemEnvironmentVariable: 'GEMSTONE' put: stoneSpec gemstonePath.
stonesRegistry destroyStoneStructureFor: stoneName.
^ stonesRegistry
%
15 changes: 1 addition & 14 deletions bin/registryReport.solo
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@ projectSetReport: projectSetName in: registry
ifAbsent: [ self error: 'No file named', projectSetPath , ' found.' ]
%
method
stoneReport: stoneName in: registry
| stonePath |
stonePath := registry
stoneNamed: stoneName
ifAbsent: [
self error: ' No stone named: ',
stoneName, ' found in the registry ',
registry name].
^ (self globalNamed: 'GDKAbstractRegistryStore')
fromPath: stonePath
ifAbsent: [ self error: 'No file named', stonePath , ' found.' ]
%
method
templateReport: templateName in: registry
| templatePath |
templatePath := registry
Expand Down Expand Up @@ -125,7 +112,7 @@ doit
ifNil: [
self stone
ifNil: [ ^ stonesRegistry ]
ifNotNil: [:stoneName | ^ self stoneReport: stoneName in: stonesRegistry ] ]
ifNotNil: [:stoneName | ^ stonesRegistry stoneNamed: stoneName ] ]
ifNotNil: [:templateName | ^ self templateReport: templateName in: stonesRegistry ] ]
ifNotNil: [:projectSetName | ^ self projectSetReport: projectSetName in: stonesRegistry ] ].
self stone ifNotNil: [ self error: 'a --registry is required to list the stone' ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ creation/destruction
createStoneStructureUsing: stonesRegistry
"create stone"

| stoneDirSpec |
self rootDir ensureCreateDirectory.
stonesRegistry productNamed: self gemstoneVersionString.
self
stoneDirectorySpec:
((GDKAbstractRegistryStore
fromPath: (stonesRegistry templateNamed: self stoneDirectorySpecName)
ifAbsent: [ ]) createStoneStructure: self) "populate directory structure"
stoneDirSpec := GDKAbstractRegistryStore
fromPath: (stonesRegistry templateNamed: self stoneDirectorySpecName)
ifAbsent: [ ].
stoneDirSpec createStoneStructure: self. "populate directory structure"
self stoneDirectorySpec: stoneDirSpec
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ creation/destruction
destroyStoneStructure
"destroy stone structure"

"need to make sure that stone and netldi are shut down, for now delete stone directory and registry file"
"shut down stone BEFORE calling"

(self waitStone: 1) ~= 3
ifTrue: [
self
error:
'The stone ' , self stoneName
,
' is still running. It must be stopped BEFORE destroying the stone structure' ].
self rootDir exists
ifTrue: [ self rootDir ensureDeleteAll ].
self registryFile exists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
runtime
startStone: superDoitScript
| arrayOfOutputs stoneLogFile |
superDoitScript stdout
startStone: superDoitScriptOrNil
| arrayOfOutputs stoneLogFile stdout scriptPath |
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitScriptOrNil stdout ]
ifNil: [
scriptPath := ''.
GsFile stdout ].
stdout
lf;
nextPutAll:
'====== ' , superDoitScript scriptPath , ' starting stone at '
, DateAndTime now printString;
'====== ' , scriptPath , ' starting stone at ' , DateAndTime now printString;
lf;
lf.
self defineCustomEnvVars.
Expand All @@ -22,14 +28,14 @@ startStone: superDoitScript
stoneLog := stoneLogFile asFileReference.
stoneLog exists
ifFalse: [ ^ ex pass ].
superDoitScript stdout
stdout
nextPutAll: stoneLog contents;
lf.
superDoitScript stdout
stdout
nextPutAll: '****************************************';
lf.
^ self ].
superDoitScript stdout nextPutAll: (arrayOfOutputs at: 1). "stdout"
superDoitScript stdout
^ self error: 'Stone did not start' ].
stdout nextPutAll: (arrayOfOutputs at: 1). "stdout"
stdout
nextPutAll: '****************************************';
lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
runtime
stopStone: superDoitScriptOrNil
| exitStatus arrayOfOutputs stdout scriptPath |
scriptPath := ''.
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitScriptOrNil stdout ]
ifNil: [ GsFile stdout ].
stdout
lf;
nextPutAll:
'====== ' , scriptPath , ' stopping stone at ' , DateAndTime now printString;
lf;
lf.
exitStatus := 0.
[
arrayOfOutputs := (Rowan globalNamed: 'GsStopStone')
stopStone: self stoneName
userName: self userId
password: self password ]
on: ChildError
do: [ :ex |
" stopstone exit status:
* 0 (success) Successful stop
* 1 (informational) No running stone with that stonename
* 2 (warning)
* 3 or above (error) an error occurred and the specified stone was not stopped.
* 10 syntax error
* 11 bad user or password
* 12 specified user does not have privilege to stop the stone.
* 13 stone not stopped; other users logged in. Use -i to override."
exitStatus := ex status ].
exitStatus = 0
ifTrue: [ stdout nextPutAll: (arrayOfOutputs at: 1) "stdout" ]
ifFalse: [
exitStatus = 1
ifTrue: [
stdout
nextPutAll: 'No running stone with the name ' , self stoneName printString;
lf ]
ifFalse: [
exitStatus = 2
ifTrue: [
stdout
nextPutAll: 'warning ';
lf ]
ifFalse: [
(exitStatus >= 3 and: [ exitStatus <= 9 ])
ifTrue: [
stdout
nextPutAll: 'Stone not stopped';
lf ]
ifFalse: [
exitStatus = 10
ifTrue: [
stdout
nextPutAll: 'Syntax error. Stone not stopped';
lf ]
ifFalse: [
exitStatus = 11
ifTrue: [
stdout
nextPutAll: 'Bad user or password. Stone not stopped';
lf ]
ifFalse: [
exitStatus = 12
ifTrue: [
stdout
nextPutAll:
'Specified user does not have privilege to stop the stone. Stone not stopped';
lf ]
ifFalse: [
exitStatus = 13
ifTrue: [
stdout
nextPutAll:
'other users logged in. Use -i to override Stone not stopped';
lf ] ] ] ] ] ] ].
self error: 'Stone not stopped' ].
stdout
nextPutAll: '****************************************';
lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runtime
stopStone
self stopStone: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
runtime
waitStone: timeout
"return exit status of waitstone command"

| exitStatus |
exitStatus := 0.
[
(Rowan globalNamed: 'GsWaitStone')
waitForStoneName: self stoneName
timeout: timeout ]
on: ChildError
do: [ :ex |
" stopstone exit status:
0 if the server (netldi or stone) is ready,
1 if the server is already already servicing the maximum number of sessions,
2 if the server is rejecting connections during startup or shutdown,
3 if the server was not found."
exitStatus := ex status ].
^ exitStatus

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
stone management
destroyStoneStructureFor: stoneName
| stoneSpec status |
stoneSpec := self stoneNamed: stoneName.
(stoneSpec waitStone: 1) = 0
ifTrue: [
| count |
"if running, stop the stone"
stoneSpec stopStone.
count := 0.
[ (status := stoneSpec waitStone: 1) ~= 3 ]
whileTrue: [
"ensure the stone has shut down, before destroying directory structure"
count := count + 1.
count > 2
ifTrue: [ self error: 'Cannot stop stone' ].
Delay waitForSeconds: 1 ] ].
stoneSpec destroyStoneStructure.
self stones removeKey: stoneName.
self export
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
accessing
stoneNamed: stoneName ifAbsent: absentBlock
^ self stones at: stoneName ifAbsent: absentBlock
| stonePath |
stonePath := self stones at: stoneName ifAbsent: absentBlock.
^ GDKAbstractRegistryStore fromPath: stonePath ifAbsent: absentBlock

0 comments on commit 3f3006f

Please sign in to comment.