pharo-server.sh

Download, install and run a Pharo Smalltalk HTTP Server using a single command

How easy and how fast can you download, install and start a complete Pharo Smalltalk based HTTP Server on a bare Linux machine ?

$ curl http://zn.stfx.eu/zn/pharo-server.sh | bash

The above Linux command will download, install and run a Pharo Smalltalk HTTP Server on a stock Linux server. In well under a minute (in 10 seconds below, actually), you can browse http://localhost:1701 and all this with way less than 20Mb being downloaded. Mind you, this is quick hack, for some this will be old news, for others I hope this feels like magic. Some notes:

Next is a terminal log of running this script, at the end there is a small benchmark showing what kind of performance you can expect from this setup (saving the best for last). The machine in question is an Amazon EC2 micro instance, the smallest, least powerful that you can get.

$ curl http://zn.stfx.eu/zn/pharo-server.sh | bash

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1463  100  1463    0     0   2842      0 --:--:-- --:--:-- --:--:--  357k

pharo-server.sh will download, install and start a Pharo Smalltalk HTTP server
this script needs bash, curl, tar, unzip, at least, only tested on Ubuntu
no special permissions needed, all files will reside in /home/ubuntu/pharo-server
written by Sven Van Caekenberghe - http://stfx.eu - using Pharo 2.0
starting @ Sun Jul  8 18:34:36 UTC 2012
creating work directory /home/ubuntu/pharo-server
downloading latest Pharo 2.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   287    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 16.5M  100 16.5M    0     0  2244k      0  0:00:07  0:00:07 --:--:-- 2075k
extracting
Archive:  pharo.zip
  inflating: Pharo-2.0/Pharo-2.0.changes  
  inflating: Pharo-2.0/PharoV10.sources  
  inflating: Pharo-2.0/Pharo-2.0.image  
downloading latest Pharo Cog VM
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   303    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  605k  100  605k    0     0   552k      0  0:00:01  0:00:01 --:--:-- 9308k
extracting
Archive:  ../cog-vm.zip
  inflating: CogVM                   
  inflating: libB3DAcceleratorPlugin.so  
  inflating: libFT2Plugin.so         
  inflating: libInternetConfigPlugin.so  
  inflating: libSqueakFFIPrims.so    
  inflating: vm-display-null         
  inflating: vm-display-X11          
  inflating: vm-sound-ALSA           
  inflating: vm-sound-null           
downloading st-exec
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2566  100  2566    0     0  82518      0 --:--:-- --:--:-- --:--:-- 95037
creating startup script pharo-server.st
starting the server
Executing ./st-exec.sh pharo-server start Pharo-2.0
Working directory /home/ubuntu/pharo-server
Starting pharo-server in background
/home/ubuntu/pharo-server/bin/CogVM -vm-display-null -vm-sound-null /home/ubuntu/pharo-server/Pharo-2.0.image /home/ubuntu/pharo-server/pharo-server.st
to stop the server execute
/home/ubuntu/pharo-server/st-exec.sh pharo-server stop Pharo-2.0
you can now access the server at
http://localhost:1701
try
curl http://localhost:1701
or
try
ab -k -n 1024 -c 8 http://localhost:1701/bytes
done @ Sun Jul  8 18:34:46 UTC 2012

$ curl http://localhost:1701

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Zinc HTTP Components</title>
<style type="text/css">
body {
  color: black;
  background: white;
  width: 900px;
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: 13px;
}
p {
  width: 600px;
  padding: 0 20px 10px 20px;
} 
ul,ol {
  width: 600px;
  padding: 0 5px 5px 30px;
} 
#logo {
  color: orange;
  font-family: Helvetica, sans-serif;
  font-weight: bold;
  font-size: 100px;
}
</style>
</head>
<body>
<div id="logo">Zn</div>
<h1>Zinc HTTP Components</h1>
<p>
Welcome to Zinc HTTP Components, 
a modern, open-source Smalltalk framework to deal with the HTTP networking protocol.
</p>
<ul>
<li>Project homepage <a href="http://zn.stfx.eu/">http://zn.stfx.eu</a></li> 
<li>Locally available pages <a href="/help">/help</a></li>
</ul>
<h4>May the Source be with you!</h4>
</body>
</html>

$ ab -k -n 1024 -c 8 http://localhost:1701/bytes

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 102 requests
Completed 204 requests
Completed 306 requests
Completed 408 requests
Completed 510 requests
Completed 612 requests
Completed 714 requests
Completed 816 requests
Completed 918 requests
Completed 1020 requests
Finished 1024 requests


Server Software:        Zinc
Server Hostname:        localhost
Server Port:            1701

Document Path:          /bytes
Document Length:        64 bytes

Concurrency Level:      8
Time taken for tests:   0.409 seconds
Complete requests:      1024
Failed requests:        0
Write errors:           0
Keep-Alive requests:    1024
Total transferred:      243712 bytes
HTML transferred:       65536 bytes
Requests per second:    2505.89 [#/sec] (mean)
Time per request:       3.192 [ms] (mean)
Time per request:       0.399 [ms] (mean, across all concurrent requests)
Transfer rate:          582.42 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       3
Processing:     0    3  33.1      0     404
Waiting:        0    3  33.1      0     404
Total:          0    3  33.2      0     406

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      0
  95%      1
  98%      2
  99%      4
 100%    406 (longest request)

pharo-server.st is a project by stfx.eu.