Dynamic Web Development with Seaside

5.2Operating the GNU Smalltalk virtual machine remotely

At the end of the previous section you created a new image from the GNU Smalltalk read-eval-print loop. If you’re familiar with other Smalltalk, it is a sort of console-based Transcript; if you’re familiar with other scripting languages you will have already recognized it.

From now on, however, you will run Seaside applications within a remote-controlled instance of GNU Smalltalk, running in background as a daemon. The following three commands start the daemon, print the daemon’s process id, and finally stop the daemon.

$ gst-remote -I seaside.im --daemon
$ gst-remote --pid
$ gst-remote --kill

The first command has the --daemon command-line option, and hence starts an instance of GNU Smalltalk that will run in the background and will be used to serve web pages. The other two don’t have the command-line option, and all they do is interacting with the background instance of GNU Smalltalk. Note that you don’t need to specify the image unless you are starting the background instance of GNU Smalltalk, because only the background virtual machine needs to have the Seaside packages loaded.

Now, let’s start the daemon again and also start the web server:

$ gst-remote -I seaside.im --daemon
$ gst-remote --start=Seaside

Seaside is now serving on http://localhost:8080/; the entry address is by default http://localhost:8080/seaside. Try visiting the http://localhost:8080/seaside/examples/counter URL to make sure that the system works.

You can stop and restart the server without killing the daemon by running:

$ gst-remote --stop=Seaside

Be sure to restart serving web pages after running this command.

Another common operation is loading a file into the remote GNU Smalltalk instance. You do this using the following expression.

$ gst-remote --file FILENAME.st

You can also control an instance of GNU Smalltalk that’s running in background using gst-remote --eval. After --eval you put a Smalltalk command that is executed within the server, for example:

$ gst-remote --eval '100 factorial printNl'

will compute 100! in the background image and print the result.

gst-remote supports running commands on a virtual machine running on a different machines, by specifying a hostname right after the command name itself. Note that, in this case, arguments to --file still refer to paths on the local machine.

Copyright © 22 April 2024 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.