Skip to content

Commit

Permalink
Issue #4: implement stopNetldi.solo ... tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehenrich committed Jun 1, 2023
1 parent 1a84d16 commit 2295395
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 30 deletions.
37 changes: 29 additions & 8 deletions bin/startNetldi.solo
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
#!/usr/bin/env superdoit_solo
options
customoptions
{
SuperDoitOptionalOptionWithNoArg long: 'help'.
SuperDoitOptionalOptionWithNoArg long: 'debug'.
SuperDoitOptionalOptionWithNoArg long: 'debugGem'.
SuperDoitOptionalOptionWithRequiredArg long: 'registry'.
SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'.
SuperDoitOptionalOptionWithNoArg long: 'verbose'.
SuperDoitOptionalOptionWithNoArg long: 'debugLogging' short: 'd'.
SuperDoitOptionalOptionWithNoArg long: 'restart' short: 'r'.
}
%
Usage
-----
USAGE $basename [--help | -h] [--debug | -D] [--debugGem] [-v | --verbose] \
USAGE $basename [--help] [--debug] [--debugGem] [--verbose] \
--registry=<registry-name> <stone-name>

DESCRIPTION
Start netldi for named stone.

OPTIONS
-h, --help display usage message
-D, --debug bring up topaz debugger in the event of a script error
Note that the standard shortcuts options are not supported, since we weant
to be faithful to the startnetldi options and they comprise a big chunk
of the alphabet.

--help display usage message
--debug bring up topaz debugger in the event of a script error
--debugGem If terminal is connected to stdout, bring up debugger. If not,
dump stack to stdout and wait for topaz to attach using topaz
DEBUGGEM command.
-v, --verbose Verbose logging enabled.
--verbose Verbose logging enabled.
#
# standard startnetldi options (currently supported)
#
-d, --debugLogging cause netldi to print extra information to its log file.
-r, --restart if a netldi with the specified name is already running,
stop the running netldi and restart it.


EXAMPLES
$basename --help
$basename -D
$basename --debug
$basename --debugGem
$basename --registry=bosch bosch_370
$basename --registry=bosch bosch_370 -r
$basename --registry=bosch bosch_370 -d
# if launched from stone directory where .GDKStoneSpec.ston is present
$basename
$basename -r
$basename -d
-----
%
specs
Expand Down Expand Up @@ -87,6 +108,6 @@ doit
ifNil: [ self error: '--registry option must be specified when <stone-name> is specified' ].
stonesRegistry := registryClass stonesRegistryNamed: self registry.
stoneSpec := stonesRegistry stoneNamed: stoneName ].
stoneSpec startNetldi: self.
stoneSpec startNetldi: self withSuperDoitOptions: true.
^ self noResult
%
11 changes: 10 additions & 1 deletion bin/startStone.solo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
options
{
SuperDoitOptionalOptionWithRequiredArg long: 'registry'.
SuperDoitOptionalOptionWithNoArg long: 'netldi' short: 'b'.
SuperDoitOptionalOptionWithNoArg long: 'startNetldi' short: 'b'.
SuperDoitOptionalOptionWithNoArg long: 'restart' short: 'r'.
SuperDoitOptionalOptionWithNoArg long: 'notranlogs' short: 'N'.
SuperDoitOptionalOptionWithNoArg long: 'restore' short: 'R'.
Expand Down Expand Up @@ -46,6 +46,13 @@ EXAMPLES
$basename --registry=bosch bosch_370 -r
$basename --registry=bosch bosch_370 -N
$basename --registry=bosch bosch_370 -w 5
# if launched from stone directory where .GDKStoneSpec.ston is present
$basename
$basename -b
$basename -r
$basename -N
$basename -w 5

-----
%
specs
Expand Down Expand Up @@ -113,5 +120,7 @@ doit
status := stoneSpec waitStone: waitTime asNumber.
status != 0
ifTrue: [ self error: 'The stone did not start within ', waitTime, ' seconds.' ] ].
self startNetldi
ifTrue: [ stoneSpec startNetldi ].
^ self noResult
%
93 changes: 93 additions & 0 deletions bin/stopNetldi.solo
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env superdoit_solo
options
{
SuperDoitOptionalOptionWithRequiredArg long: 'registry'.
SuperDoitOptionalOptionWithNoArg long: 'verbose'.
}
%
Usage
-----
USAGE $basename [--help] [--debug] [--debugGem] [--verbose] \
--registry=<registry-name> <stone-name>

DESCRIPTION
Stop netldi for named stone.

OPTIONS
--help display usage message
--debug bring up topaz debugger in the event of a script error
--debugGem If terminal is connected to stdout, bring up debugger. If not,
dump stack to stdout and wait for topaz to attach using topaz
DEBUGGEM command.
--verbose Verbose logging enabled.

EXAMPLES
$basename --help
$basename --debug
$basename --debugGem
$basename --registry=bosch bosch_370
# if launched from stone directory where .GDKStoneSpec.ston is present
$basename
-----
%
specs
[
RwLoadSpecificationV2 {
#projectName : 'GsDevKit_stones',
#projectSpecFile : 'rowan/project.ston',
#componentNames : [
'Core',
'Solo'
],
#platformProperties : {
'gemstone' : {
'allusers' : {
#defaultSymbolDictName : 'Globals'
}
}
},
#comment : ''
},
RwLoadSpecificationV2 {
#projectName : 'GsCommands',
#projectSpecFile : 'rowan/project.ston',
#diskUrl : '$GEMSTONE/examples/GsCommands/projectsHome/GsCommands',
#componentNames : [
'Commands'
],
#platformProperties : {
'gemstone' : {
'allusers' : {
#defaultSymbolDictName : 'UserGlobals'
}
}
},
#comment : ''
}
]
%
doit
| registryClass stonesRegistry stoneName stoneSpec |
self preDoitSpecLoad: [:spec |
spec projectName = 'GsCommands'
ifTrue: [ spec projectsHome: '$GEMSTONE/examples/GsCommands/projectsHome' ]
ifFalse: [ spec projectsHome: self dirname asFileReference parent parent ] ].
registryClass := (self globalNamed: 'GDKRegistry').
self verbose
ifTrue: [ (self globalNamed: 'GDKGsDevKit_stonesBase') verbose: true ].
self positionalArgs size = 0
ifTrue: [
| specFile |
specFile := FileLocator workingDirectory asFileReference / '.GDKStoneSpec.ston'.
stoneSpec := (self globalNamed: 'GDKAbstractRegistryStore') fromPath: specFile ifAbsent: [] ]
ifFalse: [
self positionalArgs size > 1
ifTrue: [ self error: 'Expected a single positional argument: <stone-name>, not ', self positionalArgs size printString, ' positional arguments' ].
stoneName := self positionalArgs at: 1.
self registry
ifNil: [ self error: '--registry option must be specified when <stone-name> is specified' ].
stonesRegistry := registryClass stonesRegistryNamed: self registry.
stoneSpec := stonesRegistry stoneNamed: stoneName ].
stoneSpec stopNetldi: self withSuperDoitOptions: true.
^ self noResult
%
4 changes: 3 additions & 1 deletion bin/stopStone.solo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ options
{
SuperDoitOptionalOptionWithRequiredArg long: 'registry'.
SuperDoitOptionalOptionWithNoArg long: 'immediate' short: 'i'.
SuperDoitOptionalOptionWithNoArg long: 'netldi' short: 'b'.
SuperDoitOptionalOptionWithNoArg long: 'stopNetldi' short: 'b'.
SuperDoitOptionalOptionWithRequiredArg long: 'timeout' short: 't'.
SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'.
}
Expand Down Expand Up @@ -105,5 +105,7 @@ doit
stonesRegistry := registryClass stonesRegistryNamed: self registry.
stoneSpec := stonesRegistry stoneNamed: stoneName ].
stoneSpec stopStone: self withSuperDoitOptions: true.
self stopNetldi
ifTrue: [ stoneSpec stopNetldi ].
^ self noResult
%

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runtime
startNetldi
self startNetldi: nil withSuperDoitOptions: false
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
runtime
startNetldi: superDoitScriptOrNil withSuperDoitOptions: superDoitOptions
"nothing special with regards to options at the present time"
startNetldi: superDoitScriptOrNil withSuperDoitOptions: superDoitOptionsBoolean
"if superDoitOptionsBoolean is true, then superDoitScriptOrNil is expected to respond to the following messages:
debugLogging
restart"

| scriptPath stdout exitStatus commandLine arrayOfOutputs |
| scriptPath stdout exitStatus commandLine arrayOfOutputs debugLogging restart |
scriptPath := ''.
restart := debugLogging := false.
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitOptionsBoolean
ifTrue: [
debugLogging := superDoitScriptOrNil debugLogging.
restart := superDoitScriptOrNil restart ].
superDoitScriptOrNil stdout ]
ifNil: [ GsFile stdout ].
stdout
Expand All @@ -21,8 +28,20 @@ startNetldi: superDoitScriptOrNil withSuperDoitOptions: superDoitOptions
add: ' -a ' , (System gemEnvironmentVariable: 'USER');
add: ' -P ' , self stoneDirectorySpec netldiPort asString;
add: ' -l ' , (self logsDir / 'netldi.log') pathString;
yourself.
debugLogging
ifTrue: [ commandLine add: ' -d' ].
restart
ifTrue: [ commandLine add: ' -r' ].
commandLine
add: ' ' , self stoneName , '_ldi';
yourself.
GDKGsDevKit_stonesBase verbose
ifTrue: [
stdout
lf;
nextPutAll: commandLine;
yourself ].
[ arrayOfOutputs := GsHostProcess execute: commandLine ]
on: ChildError
do: [ :ex |
Expand All @@ -36,10 +55,10 @@ startNetldi: superDoitScriptOrNil withSuperDoitOptions: superDoitOptions
ifTrue: [ stdout nextPutAll: (arrayOfOutputs at: 1) "stdout" ]
ifFalse: [
(exitStatus = 1 or: [ exitStatus = 2 ])
ifTrue: [ stdout nextPutAll: 'netldi is already running' ]
ifTrue: [ stdout nextPutAll: 'netldi is already running (' , exitStatus printString , ')' ]
ifFalse: [
exitStatus >= 3
ifTrue: [ stdout nextPutAll: 'netldi failed to start' ] ] ].
ifTrue: [ stdout nextPutAll: 'netldi failed to start (' , exitStatus printString , ')' ] ] ].
stdout
lf;
nextPutAll: '****************************************';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
runtime
startStone

self startStone: nil withSuperDoitOptions: false
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ startStone: superDoitScriptOrNil withSuperDoitOptions: superDoitOptionsBoolean
notranlogs
restore"

| arrayOfOutputs stoneLogFile stdout scriptPath notranlogsMode restorMode |
notranlogsMode := restorMode := false.
| arrayOfOutputs stoneLogFile stdout scriptPath notranlogsMode restoreMode |
notranlogsMode := restoreMode := false.
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitOptionsBoolean
ifTrue: [
notranlogsMode := superDoitScriptOrNil notranlogs.
restorMode := superDoitScriptOrNil restore ].
restoreMode := superDoitScriptOrNil restore ].
superDoitScriptOrNil stdout ]
ifNil: [
scriptPath := ''.
Expand All @@ -35,7 +35,7 @@ startStone: superDoitScriptOrNil withSuperDoitOptions: superDoitOptionsBoolean
sysConfFile: self sysConfFile pathString
logFile: stoneLogFile
noTranlogs: notranlogsMode
restoreMode: restorMode
restoreMode: restoreMode
conversionMode: false ]
on: ChildError
do: [ :ex |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runtime
stopNetldi
self stopNetldi: nil withSuperDoitOptions: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
runtime
stopNetldi: superDoitScriptOrNil withSuperDoitOptions: superDoitOptionsBoolean
"if superDoitOptionsBoolean is true, then superDoitScriptOrNil is expected to respond to the following messages:
debugLogging
restart"

| scriptPath stdout exitStatus commandLine arrayOfOutputs |
scriptPath := ''.
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitScriptOrNil stdout ]
ifNil: [ GsFile stdout ].
stdout
lf;
nextPutAll: '====== stopping netldi at ' , DateAndTime now printString;
lf.
exitStatus := 0.
self defineCustomEnvVars.
commandLine := '$GEMSTONE/bin/stopnetldi' asFileReference pathString.
commandLine
add: ' ' , self stoneName , '_ldi';
yourself.
GDKGsDevKit_stonesBase verbose
ifTrue: [
stdout
lf;
nextPutAll: commandLine;
yourself ].
[ arrayOfOutputs := GsHostProcess execute: commandLine ]
on: ChildError
do: [ :ex |
"exit status:
0 on successful stop
1 if the specified netldi was not running
3 or above, an error occurred and the specified netldi could not be stopped"
exitStatus := ex status ].
exitStatus = 0
ifTrue: [ stdout nextPutAll: (arrayOfOutputs at: 1) "stdout" ]
ifFalse: [
exitStatus = 1
ifTrue: [ stdout nextPutAll: 'netldi was not running (' , exitStatus printString , ')' ]
ifFalse: [
exitStatus >= 3
ifTrue: [
stdout
nextPutAll:
'netldi could not be stopped (' , exitStatus printString , ')' ] ] ].
stdout
lf;
nextPutAll: '****************************************';
lf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
runtime
stopStone
self stopStone: nil
self stopStone: nil withSuperDoitOptions: false

0 comments on commit 2295395

Please sign in to comment.