[Cuis-dev] Cuis headless
Juan Vuletich
juan at jvuletich.org
Wed Apr 22 09:28:30 PDT 2020
Hi Erik!
On 4/21/2020 3:55 PM, Erik Stel via Cuis-dev wrote:
> Hi,
>
> Big kudos to the Cuis community! Up to now I have been a very passive participant (ie reader), but I really like the helpful atmosphere and good discussions.
> I’ve been I’ve been using Cuis next to some other Smalltalk dialects and I really appreciate the philosophy. I am building a learning environment for kids and want to use Cuis for this because of this philosophy.
Nice!
> I have a question regarding headless Cuis:
> Is there a working/standard approach for creating a headless image for Cuis? I would like to run images on a server and therefore do not need the whole GUI part for those images. Removing it from an image is one option, but maybe there is a sort of bootstrap process to create an initial headless image as well.
We don't have a bootstrap process yet. Although it would be something
really nice to have, nobody has yet given this enough priority to put
serious effort. Completely removing Morphic is an option, but there are
others too.
If you will run many images and care about image size, just doing
`StrikeFont saveSpace.` will save 3Mb. I'm sure it is reasonably easy to
shave at least another Mb.
If you want to avoid running Morphic, but don't mind having it loaded in
the image (it might be good to be able to start Morphic if necessary,
for example for debugging), then take a look at
#snapshot:andQuit:embedded:clearAllClassState: . On every image save we
stop the Morphic process, and create a new one on startup. So, to avoid
running Morphic at all, you can disable the following lines (haven't
tried it!)
UISupervisor spawnNewMorphicProcessFor: (guiRootObject ifNil: [
guiRootObject _ guiRootObjectClass newWorld ]).
Display triggerEvent: #screenSizeChanged.
self restoreLostChangesIfNecessary.
clearAllStateFlag ifTrue: [
UISupervisor whenUIinSafeState: [
guiRootObject recreateDefaultDesktop ]].
Additionally, take a look at AppLauncher . It is a way to to start
application specific code at startup. To set up an Application images,
call #appGlobalName:appSelector, and save the image. This way, your app
will run on image startup, possibly (if you disabled it as I say above)
without Morphic.
Alternatively, you can run the VM with command line arguments to run a
specific doIt that will start your stuff.
> There has been a thread (back in 2016) about a REPL-mechanism using stdio which could be helpful for removing the GUI/head. It did not seem to have lead to a headless image. I have a WebSocket-based REPL and did a short experiment, but before continuing this road I want to check there isn’t a better solution already available.
What we did some time ago is essentially only useful for debugging. The
reason is that waiting on StdIn blocks the VM, suspending all Smalltalk
code. Check the comment at StdIOReadStream. A headless image based on
this would only be useful for running user commands. It would only run
Smalltalk code for each command you type.
I think your WebSocket based REPL is a good approach, and it would be
very useful for others. Please consider contributing it to Cuis (under
MIT license, as usual).
> Any pointers are welcome.
>
> Regards,
> Erik
Cheers,
--
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich
More information about the Cuis-dev
mailing list