Skip to content

Commit

Permalink
Issue #4: implement startNetldi.solo
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehenrich committed Jun 1, 2023
1 parent a9a9474 commit 1a84d16
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 6 deletions.
92 changes: 92 additions & 0 deletions bin/startNetldi.solo
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env superdoit_solo
options
{
SuperDoitOptionalOptionWithRequiredArg long: 'registry'.
SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'.
}
%
Usage
-----
USAGE $basename [--help | -h] [--debug | -D] [--debugGem] [-v | --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
--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.


EXAMPLES
$basename --help
$basename -D
$basename --debugGem
$basename --registry=bosch bosch_370
-----
%
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 startNetldi: self.
^ self noResult
%
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ createStoneStructure: stoneSpec
stoneRoot / 'extent0.dbf' moveTo: stoneRoot / value ].
key = #'logs'
ifTrue: [ (stoneRoot / value) ensureCreateDirectory ].
key = #'netldiPort'
ifTrue: [
value = 0
ifTrue: [
| socket status |
socket := GsSocket new.
status := socket bindTo: value.
netldiPort := socket port.
socket close ] ].
key = #'stats'
ifTrue: [ (stoneRoot / value) ensureCreateDirectory ].
key = #'tranlogs'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
netldiPort: object
netldiPort := object
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
netldiPort
^netldiPort
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"bin",
"extents",
"logs",
"netldiPort",
"stats",
"tranlogs",
"snapshots",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
logsDir
| dir |
dir := self rootDir / self stoneDirectorySpec logs.
dir ensureCreateDirectory.
^ dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runtime
startNetldi: superDoitScriptOrNil
self startNetldi: superDoitScriptOrNil withSuperDoitOptions: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
runtime
startNetldi: superDoitScriptOrNil withSuperDoitOptions: superDoitOptions
"nothing special with regards to options at the present time"

| scriptPath stdout exitStatus commandLine arrayOfOutputs |
scriptPath := ''.
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitScriptOrNil stdout ]
ifNil: [ GsFile stdout ].
stdout
lf;
nextPutAll: '====== starting netldi at ' , DateAndTime now printString;
lf.
exitStatus := 0.
self defineCustomEnvVars.
commandLine := '$GEMSTONE/bin/startnetldi' asFileReference pathString.
commandLine
add: ' -g';
add: ' -a ' , (System gemEnvironmentVariable: 'USER');
add: ' -P ' , self stoneDirectorySpec netldiPort asString;
add: ' -l ' , (self logsDir / 'netldi.log') pathString;
add: ' ' , self stoneName , '_ldi';
yourself.
[ arrayOfOutputs := GsHostProcess execute: commandLine ]
on: ChildError
do: [ :ex |
"exit status:
0 on successful start
1 if the specified netldi is already running
2 if already running but the executable have been deleted
3 or above, an error occurred and the specified netldi was not started"
exitStatus := ex status ].
exitStatus = 0
ifTrue: [ stdout nextPutAll: (arrayOfOutputs at: 1) "stdout" ]
ifFalse: [
(exitStatus = 1 or: [ exitStatus = 2 ])
ifTrue: [ stdout nextPutAll: 'netldi is already running' ]
ifFalse: [
exitStatus >= 3
ifTrue: [ stdout nextPutAll: 'netldi failed to start' ] ] ].
stdout
lf;
nextPutAll: '****************************************';
lf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
runtime
stopStone: superDoitScriptOrNil withSuperDoitOptions: superDoitOptionsBoolean
"if superDoitOptionsBoolean is true, then superDoitScriptOrNil is expected to respond to the following messages:
scriptPath
immediate
timeout"

Expand All @@ -10,6 +11,7 @@ stopStone: superDoitScriptOrNil withSuperDoitOptions: superDoitOptionsBoolean
immediate := false.
stdout := superDoitScriptOrNil
ifNotNil: [
scriptPath := superDoitScriptOrNil scriptPath.
superDoitScriptOrNil timeout ifNotNil: [ :value | timeout := value asNumber ].
immediate := superDoitScriptOrNil immediate.
superDoitScriptOrNil stdout ]
Expand Down
1 change: 1 addition & 0 deletions templates/default.ston
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GDKhomeStoneDirectorySpec{
#customenv: 'customenv',
#extents : 'extents',
#logs : 'logs',
#netldiPort : 0,
#stats : 'stats',
#tranlogs : 'tranlogs',
#snapshots : 'snapshots',
Expand Down
1 change: 1 addition & 0 deletions templates/default_rowan.ston
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GDKstonesStoneDirectorySpec {
#dbfSource : '$GEMSTONE/bin/extent0.rowan.dbf',
#extents : 'extents',
#logs : 'logs',
#netldiPort : 0,
#stats : 'stats',
#tranlogs : 'tranlogs',
#snapshots : 'snapshots',
Expand Down
1 change: 1 addition & 0 deletions templates/default_seaside.ston
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GDKhomeStoneDirectorySpec {
#dbfSource : '$GEMSTONE/bin/extent0.seaside.dbf',
#extents : 'extents',
#logs : 'logs',
#netldiPort : 0,
#stats : 'stats',
#tranlogs : 'tranlogs',
#snapshots : 'snapshots',
Expand Down
1 change: 1 addition & 0 deletions templates/minimal.ston
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ GDKstonesStoneDirectorySpec {
#customenv: 'customenv',
#bin : 'bin',
#logs : 'logs',
#netldiPort : 0,
#userId : 'SystemUser'
}
1 change: 1 addition & 0 deletions templates/minimal_rowan.ston
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ GDKstonesStoneDirectorySpec {
#dbfSource : '$GEMSTONE/bin/extent0.rowan.dbf',
#bin : 'bin',
#logs : 'logs',
#netldiPort : 0,
#userId : 'SystemUser'
}
1 change: 1 addition & 0 deletions templates/minimal_seaside.ston
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ GDKstonesStoneDirectorySpec {
#dbfSource : '$GEMSTONE/bin/extent0.seaside.dbf',
#bin : 'bin',
#logs : 'logs',
#netldiPort : 0,
#userId : 'DataCurator'
}

0 comments on commit 1a84d16

Please sign in to comment.