Hello folks.
I'd like to ask, if there any 'standartized' instruments for headless images (or alike). I need a simple things: - redirect all ToolSet/UIManager messages to Transcript - redirect Transcript logging to file or stdout in short, these tools should serve a simple, yet important purpose: - if image runs in headless mode, it should suppress anything which expecting user interaction (like showing warnings with 'continue' button) and either log such messages to file or simply quit image with error message. Without such tool it is quite difficult to monitor, what happens with your headless image.. unless you have RFB installed.. but that is different and unrelated story. I did a prototype once for Hydra (you can check it at SqS/HydraVM/HydraVM.mcz package) there are two subclasses: - MorphicUIManager subclass: #HydraUIManager - StandardToolSet subclass: #HydraDebugToolSet and - WriteStream subclass: #HydraTranscript which can be installed as a Transcript. And in order to prepare image to run in headless mode, i issued: ToolSet unregister: StandardToolSet. ToolSet register: HydraDebugToolSet. UIManager default: HydraUIManager new. Also, HydraTranscript startUp does something like: TranscriptStream newTranscript: (self basicNew initialize on: (String new: 1000)) With that i could run the image in headless mode, knowing that in case of error or warning etc, all will be redirected to transcript, moreover i even stopped the UI process, so it never run on headless images. I wonder if there are other work, which can offer similar, and is there any way to detect that image are running in headless mode? -- Best regards, Igor Stasenko AKA sig. |
The Ma stack does something similar, although not crippling the system
to the same extent. How do you determine you're running headless? I attached my implementation of #maIsHeadless for determining whether the VM was launched headless. Perhaps we should integrate this functionality into Squeak and Pharo (or a variant without the prefix, of course). Then, I use MaCommandLineProcessor which is concerned with handling the command-line Squeak was launched with: Then, I write my .st scripts like: MaCommandLineProcessor do: [ : arg1 : arg2 : arg3 : etc | "my batch code script..." "args come in as Strings." "... you can have a variable number of args." ] as well as a uniform error-handler for all scripts, to redirect to stdout and stderr, thusly: MaCommandLineProcessor class>>#do: aBlock | stdOut stdErr | self ensureStartedUp. stdOut := StandardFileStream stdout. stdErr := StandardFileStream stderr. [ aBlock valueWithAllArguments: self args ] on: Notification , Warning do: [ : noti | stdOut nextPutAll: DateAndTime now asString ; space ; nextPutAll: noti description ; perform: MultiByteFileStream lineEndDefault. noti resume ] on: SyntaxErrorNotification do: [ : err | stdOut nextPutAll: err errorCode ; perform: MultiByteFileStream lineEndDefault. self haltOrQuit ] on: Error do: [ : err | stdErr nextPutAll: 'ERROR: ' ; nextPutAll: DateAndTime now asString ; space ; perform: MultiByteFileStream lineEndDefault ; nextPutAll: err description ; perform: MultiByteFileStream lineEndDefault. err isMaUserError ifFalse: [ stdErr nextPutAll: (err signalerContext longStack copyReplaceAll: Character cr asString with: (String perform: MultiByteFileStream lineEndDefault)) ]. self haltOrQuit ] #haltOrQuit is where it checks #maIsHeadless to determine whether to halt or quit. MaCommandLineProcessor is part of "Ma base additions" package, so any of the "Ma" softwares (Magma, Maui, Ma client server, etc.) will have it. But I think it would be useful to put this (or, a variant) directly into a future Squeak. - Chris On Thu, Jan 20, 2011 at 2:39 PM, Igor Stasenko <[hidden email]> wrote: > Hello folks. > > I'd like to ask, if there any 'standartized' instruments for headless > images (or alike). > > I need a simple things: > - redirect all ToolSet/UIManager messages to Transcript > - redirect Transcript logging to file or stdout > > in short, these tools should serve a simple, yet important purpose: > - if image runs in headless mode, it should suppress anything which > expecting user interaction (like showing warnings with 'continue' > button) and either log such messages to file > or simply quit image with error message. > > Without such tool it is quite difficult to monitor, what happens with > your headless image.. unless you have RFB installed.. but that is > different and unrelated story. > > > I did a prototype once for Hydra (you can check it at > SqS/HydraVM/HydraVM.mcz package) > there are two subclasses: > - MorphicUIManager subclass: #HydraUIManager > - StandardToolSet subclass: #HydraDebugToolSet > > and > - WriteStream subclass: #HydraTranscript > > which can be installed as a Transcript. > > And in order to prepare image to run in headless mode, i issued: > ToolSet unregister: StandardToolSet. > ToolSet register: HydraDebugToolSet. > UIManager default: HydraUIManager new. > > Also, HydraTranscript > startUp does something like: > > TranscriptStream > newTranscript: (self basicNew initialize > on: (String new: 1000)) > > > With that i could run the image in headless mode, knowing that in case > of error or warning etc, all will be redirected to transcript, > moreover i even stopped the UI process, so it never run on headless images. > > I wonder if there are other work, which can offer similar, > and is there any way to detect that image are running in headless mode? > > > -- > Best regards, > Igor Stasenko AKA sig. > > SmalltalkImage-maIsHeadless.st.gz (488 bytes) Download Attachment |
On 20 January 2011 22:05, Chris Muller <[hidden email]> wrote:
> The Ma stack does something similar, although not crippling the system > to the same extent. > well, if by 'crippling' you mean preventing any unwanted activity when headless.. then yes, i want it :) > How do you determine you're running headless? I attached my > implementation of #maIsHeadless for determining whether the VM was > launched headless. Perhaps we should integrate this functionality > into Squeak and Pharo (or a variant without the prefix, of course). > okay, as i suspected there is no direct way to determine that.. i don't like checking the command-line args, because obviously i can build vm which completely ignores that. but since there is no other options... > Then, I use MaCommandLineProcessor which is concerned with handling > the command-line Squeak was launched with: > > Then, I write my .st scripts like: > [snip] ohh.. well, but that is too much for a simple script. it would be good if image could provide something by default, because i don't want to repeat expressions like this in each script i write for running it in headless image. :) > > - Chris > > > On Thu, Jan 20, 2011 at 2:39 PM, Igor Stasenko <[hidden email]> wrote: >> Hello folks. >> >> I'd like to ask, if there any 'standartized' instruments for headless >> images (or alike). >> >> I need a simple things: >> - redirect all ToolSet/UIManager messages to Transcript >> - redirect Transcript logging to file or stdout >> >> in short, these tools should serve a simple, yet important purpose: >> - if image runs in headless mode, it should suppress anything which >> expecting user interaction (like showing warnings with 'continue' >> button) and either log such messages to file >> or simply quit image with error message. >> >> Without such tool it is quite difficult to monitor, what happens with >> your headless image.. unless you have RFB installed.. but that is >> different and unrelated story. >> >> >> I did a prototype once for Hydra (you can check it at >> SqS/HydraVM/HydraVM.mcz package) >> there are two subclasses: >> - MorphicUIManager subclass: #HydraUIManager >> - StandardToolSet subclass: #HydraDebugToolSet >> >> and >> - WriteStream subclass: #HydraTranscript >> >> which can be installed as a Transcript. >> >> And in order to prepare image to run in headless mode, i issued: >> ToolSet unregister: StandardToolSet. >> ToolSet register: HydraDebugToolSet. >> UIManager default: HydraUIManager new. >> >> Also, HydraTranscript >> startUp does something like: >> >> TranscriptStream >> newTranscript: (self basicNew initialize >> on: (String new: 1000)) >> >> >> With that i could run the image in headless mode, knowing that in case >> of error or warning etc, all will be redirected to transcript, >> moreover i even stopped the UI process, so it never run on headless images. >> >> I wonder if there are other work, which can offer similar, >> and is there any way to detect that image are running in headless mode? >> >> >> -- >> Best regards, >> Igor Stasenko AKA sig. >> >> > > > > -- Best regards, Igor Stasenko AKA sig. |
> ohh.. well, but that is too much for a simple script.
> it would be good if image could provide something by default, > because i don't want to repeat expressions like this in each script i > write for running it in headless image. :) Hm, you may have missed that the point of that was to _avoid_ repeating those expressions. That way, this is all your .st script has to be: CommandLineProcessor do: [ : arg1 : arg2 | "... your simple script goes here..." ] So that's not so much is it? All of the error-handling to stdout is tucked away in the image, as is the parsing of the command-line arguments. - Chris |
In reply to this post by Igor Stasenko
> well, if by 'crippling' you mean preventing any unwanted activity when
> headless.. then yes, i want it :) Forgot to say, that's what I meant too. :) I should have said, "although not enhancing system performance to the same extent." |
In reply to this post by Chris Muller-3
A big +1 to all of this. VNC is a poor substitute for command line server management in some cases, and I think it would make Squeak a *much* easier sell to my operations people. I've been wishing for something like this.
On Jan 20, 2011, at 1:05 PM, Chris Muller <[hidden email]> wrote: > The Ma stack does something similar, although not crippling the system > to the same extent. > > How do you determine you're running headless? I attached my > implementation of #maIsHeadless for determining whether the VM was > launched headless. Perhaps we should integrate this functionality > into Squeak and Pharo (or a variant without the prefix, of course). > > Then, I use MaCommandLineProcessor which is concerned with handling > the command-line Squeak was launched with: > > Then, I write my .st scripts like: > > MaCommandLineProcessor do: > [ : arg1 : arg2 : arg3 : etc | > "my batch code script..." > "args come in as Strings." > "... you can have a variable number of args." ] > > as well as a uniform error-handler for all scripts, to redirect to > stdout and stderr, thusly: > > MaCommandLineProcessor class>>#do: aBlock > | stdOut stdErr | > self ensureStartedUp. > stdOut := StandardFileStream stdout. > stdErr := StandardFileStream stderr. > [ aBlock valueWithAllArguments: self args ] > on: Notification , Warning > do: > [ : noti | stdOut > nextPutAll: DateAndTime now asString ; space ; > nextPutAll: noti description ; > perform: MultiByteFileStream lineEndDefault. > noti resume ] > on: SyntaxErrorNotification > do: > [ : err | stdOut > nextPutAll: err errorCode ; > perform: MultiByteFileStream lineEndDefault. > self haltOrQuit ] > on: Error > do: > [ : err | stdErr > nextPutAll: 'ERROR: ' ; > nextPutAll: DateAndTime now asString ; space ; > perform: MultiByteFileStream lineEndDefault ; > nextPutAll: err description ; > perform: MultiByteFileStream lineEndDefault. > err isMaUserError ifFalse: > [ stdErr nextPutAll: > (err signalerContext longStack > copyReplaceAll: Character cr asString > with: (String perform: MultiByteFileStream lineEndDefault)) ]. > self haltOrQuit ] > > #haltOrQuit is where it checks #maIsHeadless to determine whether to > halt or quit. > > MaCommandLineProcessor is part of "Ma base additions" package, so any > of the "Ma" softwares (Magma, Maui, Ma client server, etc.) will have > it. But I think it would be useful to put this (or, a variant) > directly into a future Squeak. > > - Chris > > > On Thu, Jan 20, 2011 at 2:39 PM, Igor Stasenko <[hidden email]> wrote: >> Hello folks. >> >> I'd like to ask, if there any 'standartized' instruments for headless >> images (or alike). >> >> I need a simple things: >> - redirect all ToolSet/UIManager messages to Transcript >> - redirect Transcript logging to file or stdout >> >> in short, these tools should serve a simple, yet important purpose: >> - if image runs in headless mode, it should suppress anything which >> expecting user interaction (like showing warnings with 'continue' >> button) and either log such messages to file >> or simply quit image with error message. >> >> Without such tool it is quite difficult to monitor, what happens with >> your headless image.. unless you have RFB installed.. but that is >> different and unrelated story. >> >> >> I did a prototype once for Hydra (you can check it at >> SqS/HydraVM/HydraVM.mcz package) >> there are two subclasses: >> - MorphicUIManager subclass: #HydraUIManager >> - StandardToolSet subclass: #HydraDebugToolSet >> >> and >> - WriteStream subclass: #HydraTranscript >> >> which can be installed as a Transcript. >> >> And in order to prepare image to run in headless mode, i issued: >> ToolSet unregister: StandardToolSet. >> ToolSet register: HydraDebugToolSet. >> UIManager default: HydraUIManager new. >> >> Also, HydraTranscript >> startUp does something like: >> >> TranscriptStream >> newTranscript: (self basicNew initialize >> on: (String new: 1000)) >> >> >> With that i could run the image in headless mode, knowing that in case >> of error or warning etc, all will be redirected to transcript, >> moreover i even stopped the UI process, so it never run on headless images. >> >> I wonder if there are other work, which can offer similar, >> and is there any way to detect that image are running in headless mode? >> >> >> -- >> Best regards, >> Igor Stasenko AKA sig. >> >> > <SmalltalkImage-maIsHeadless.st.gz> > |
In reply to this post by Igor Stasenko
Considerations about improving headless support need to not only be
about what to do with error output. When "running headless," the user is taking on a different kind of interaction with the system; it is now an industrial interface instead of the GUI, but it *is* a user-interface nonetheless. Therefore interacting with the system this way should address *input* as well as output. The input in the industrial environment consists of the name of a Smalltalk script + command-line arguments to that script. > this is next step.. > > I think this could be set by preference system > on error: > - print error to log and quit > - print error to log and do save & quit > - print error to log and do save new version & quit It's important to allow the same image to be used by multiple scripts, some of which might want to exit without saving, some which want to save under a new name. "How-to-quit" should be specific to each input script, not a global preference in the image. Regards, Chris |
On 21 January 2011 20:19, Chris Muller <[hidden email]> wrote:
> Considerations about improving headless support need to not only be > about what to do with error output. When "running headless," the user > is taking on a different kind of interaction with the system; it is > now an industrial interface instead of the GUI, but it *is* a > user-interface nonetheless. Therefore interacting with the system > this way should address *input* as well as output. > > The input in the industrial environment consists of the name of a > Smalltalk script + command-line arguments to that script. > >> this is next step.. >> >> I think this could be set by preference system >> on error: >> - print error to log and quit >> - print error to log and do save & quit >> - print error to log and do save new version & quit > > It's important to allow the same image to be used by multiple scripts, > some of which might want to exit without saving, some which want to > save under a new name. "How-to-quit" should be specific to each input > script, not a global preference in the image. > to run for headless images and aware about various nuances. I am talking about scripts which are quickly coded without any precautions, because most of users can't make difference between running headless and headful and where all problems can arise from.. So for such scripts image should behave adequately and not hang in undetermined state waiting an input from potential user. It should use these settings as default ones. I just wanna make life a bit easier for people :) > Regards, > Chris > > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Igor Stasenko
How are you planning to load and trigger scripts?
The man page says: "Squeak can load and execute a 'script' file containing Smalltalk code at startup." Unless there is another way to load a script I don't know about, then loading different scripts would require starting and stopping the image, which wouldn't be practicable. Chris |
Free forum by Nabble | Edit this page |