[squeak-dev] Controlling a headless server Squeak through VNC

Chris Muller asqueaker at gmail.com
Sat Dec 3 23:29:12 UTC 2022


Oh.  I thought you said you had upgraded squeaksource.com to utilize the
new source.squeak.org/ss code, Personal SqueakSource.  Is that not the case?

That code tackles this use-case from a 100% headless approach (no Morphs
involved) by simply putting a "Smalltalk mitigateIfHeadless" as the first
line within the Smalltalk run: [] block.

   Smalltalk run:
       [ Smalltalk mitigateIfHeadless.
       ... ]

Here's that method:
    ____
    mitigateIfHeadless
        self isHeadless ifTrue: [ self headlessMitigation ]
    ____
    headlessMitigation
        "If I'm headless and RFB is present, start an RFBServer on port
identified by rfbPort."
        (Smalltalk classNamed: #RFBServer) ifNotNil:
            [ : rfbServer |
            rfbServer
                allowRemoteConnections: false ;  "<--- check this out"
                allowEmptyPasswords: true ;
                setFullPassword: nil ;
                setViewPassword: nil ;
                start: (self rfbPort ifNil: [ 5900 ])-5900 ]

By allowing only local connections (which is what Dave's ssh tunnel
accomplishes -- even when the server is remote), the port is able to be
left open all the time, so there's no need to signal the process, and no
need to leave the server exposed even for 1 minute.

As you can see, this also allows multiple images on the same server to use
different RFB ports / screens, instead of only 5901 / :1, by way of an
"rfbPort" file.

A lot of work went into making Personal SqueakSource the most-thought-out,
most-documented[1], easiest-to-setup, most-maintained and bug-free version
of SqueakSource available.  All the fixes and workspace scripts from the
old squeaksource.com image were incorporated long ago.  I thought you had
already switched over to it, Dave.  I believe community collaboration on a
unified (vs. forked) code base for our SCM tool is beneficial.  Personal
SqueakSource is also the only one able to provide class and method-level
revision history for one's own private code.

 - Chris

[1] -- https://wiki.squeak.org/squeak/6365


On Sat, Dec 3, 2022 at 3:03 PM David T. Lewis <lewis at mail.msen.com> wrote:

> During a recent board discussion, Tim asked about experiences in using VNC
> to control server images. There are various ways to do this, but here is
> how
> it is done for the https://squeaksource.com server. The easiest way to see
> how it works is to try it out on your own computer, so here is what to do:
>
> - Start with a fresh Squeak image.
> - Open a Monticello Browser, and add repository
> http://source.squeak.org/ss.
> - Open the repository and navigate to category update.sscom.
> - Select update.sscom-dtl.5.mcm and load it.
>
> When loading is complete, you will see a notifier saying that SqueakSource
> is running on port 8888, as well as a pinnable morph for controlling the
> RFBServer (for VNC connections).
>
> Pin the RFB control morph so that it stays active. If you close it by
> accident, do "RFBServer menu openInWorld" to get it back.
>
> Save the image once and restart it to make sure the startup initialization
> is working.
>
> You can now open a web browser on http://localhost:8888 to connect to
> the SqueakSource web interface. Only one account will be present in the
> repository, this is your administrative user with user name 'admin' and
> password 'password'. Changing that password (from the web interface) is
> a good idea.
>
> The following will work only on Unix/Linux/OSX:
>
> In the RFBServer menu, in the passwords menu, select "allow empty
> passwords"
>
> In a terminal window (outside of Squeak), identify the pid of the Squeak VM
> process (pgrep -l squeak).
>
> From the terminal, send a SIGUSR2 signal to the VM process. If the Squeak
> VM pid is 1234, then the command is "kill -SIGUSR2 1234".
>
> Back in the Squeak image, you will see the VNC control change from
> "RFBServer (stopped)" to "RFBServer :1" to indicate that it is accepting
> VNC connections on display number 1. It will stay in this state for the
> next 60 seconds.
>
> From a VNC client program running on the local machine, connect to
> localhost:1, and you should have an active connection to the Squeak image.
>
> If you want to run your SqueakSource image on another server, run the
> VM with -vm-display-null and use ssh port forwarding if needed to access
> the VNC ports.
>
> For example, I have a unix account on the server that hosts
> squeaksource.com.
> When I want to open the running SqueakSource image through VNC, I first
> log in to the Linux server with a command like this (except that 10.1.2.3
> is not the real address that we are using).
>
> $ ssh -L8888:localhost:8888 -L5900:localhost:5900 -L5901:localhost:5901
> 10.1.2.3
>
> Once logged in, I locate the Squeak VM process and send SIGUSR2 to it. I
> keep
> the login session open to handle the port forwarding while I use VNC.
>
> Then back on my local computer, I open a VNC connection to localhost:1 to
> get a connection to the running image. This step needs to be done within 60
> seconds of the SIGUSR2, after than no further connections will be accepted.
>
> I used to use a VNC password (settable from the RFBServer menu) but I
> decided
> that it was too much hassle given the 60 second connection enablement
> window,
> which can only be started by someone with login access to the server and
> sufficient privilege to send signals to the VM process.
>
> If you want to copy any of these ideas for use in some other Squeak server
> application, the interesting bits are in class SSImageInit, especially
> SSImageInit class>>enableFRBServerOnSigUsr2.
>
> I should note that RFBServer is written by Ian Piumarta. I don't recall
> where it was originally hosted, but a copy of RFB-ikp.8.mcz is in our
> source.squeak.org/ss repository, along with later updates that are
> currently
> in use for SqueakSource.
>
> Dave
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221203/ca2a2b4f/attachment.html>


More information about the Squeak-dev mailing list