(ˢᵒᶜⁱᵉᵗʸlog)
(ˢᵒᶜⁱᵉᵗʸserver)
(ˢᵒᶜⁱᵉᵗʸtask)
Chandler
REST
angular.js
coding-for-fun
cordova
css
hackerspace
installation
javascript
mockups
multi-language
nReduce
pike
publishing
retreat
sTeam
stylesheets
user-interface
virtual hosting
xiamen

The REST API is developed as an application inside the sTeam server. This simplifies development quite a lot, as we don't need to restart the server for every change. Instead the just the API code gets updated and reloaded. It may eventually be integrated into the core, however the longterm plan is actually to move functionality out of the core, to make development easier.

Over the summer, Trilok has been improving the export and import tools, so now we can finally export the whole development history of the REST API to git, and we can import that git history into other servers. Using git, we can also easily merge development done on different servers.

To get the current version of the API clone the repo into your home or to any place where you keep your development repos. Then change to the tools directory of your installation and run import-to-git.

git clone https://github.com/societyserver/steam-rest
cd steam-rest
git checkout origin/rest.pike
export steamrest=`pwd`
cd /usr/local/lib/steam/tools
./import-from-git.pike -u root $steamrest /

It is important that the first import is done as root because the API code needs to run with root privileges and it will only do that if the object that holds the source is created as root.

Once the api code is loaded there are just a few tweaks needed to make it work.

We need to fix the mime-type, as the import script is not doing that yet.

OBJ("/sources/rest.pike")->set_attribute("DOC_MIME_TYPE", "source/pike");

changing the mimetype will change the class of the rest api script from Document to DocLpc.

> OBJ("/sources/rest.pike");                                               
(1) Result: 127.0.0.1:1900/rest.pike(#840,/classes/Document,17,source/pike)
> OBJ("/sources/rest.pike");                                               
(2) Result: 127.0.0.1:1900/rest.pike+(#840,/classes/DocLpc,529,source/pike,0 Instances, ({  }))

this takes a moment, check the type a few times until it's done.

Then instantiate an object from the source, give it a proper name, and move it to the /scripts/ container"

object rest = OBJ("/sources/rest.pike")->provide_instance();
rest->set_attribute("OBJ_NAME", "rest.pike");
rest->move(OBJ("/scripts/"));

Instantiating the object needs to be done as sTeam-root, in order for it to have permissions to run on behalf of other users.

Once this is done you are ready to start using the API.

Author :mbaehr   |   size :2603Bytes   |   Publish Date :Jan/14/16/08:18   |   to Top

After you installed and set up a basic sTeam server, you'll want to update to the latest development state. there are some significant changes in there, some of which are documented in the articles below.

Because we don't have a way to run a development server directly from the source repo, and we don't want to reinstall for every change, we instead track changes in a runtime repo directly from the directory where the server is installed. This will change eventually, but probably not until we have restored the original sTeam development history.

To get this runtime repo, you first clone https://github.com/societyserver/sTeam.git to a temporary directory:

cd /tmp
git clone https://github.com/societyserver/sTeam.git
cd sTeam

and check out the version that matches an initial installation:

git checkout 49a79885aa509427c818f8ecc6bf3c78e056b4be;

the worktree should now match your installation except for a few files. we can now copy the .git directory to our installation:

cp -avi .git /usr/local/lib/steam/;

and verify it:

cd /usr/local/lib/steam/;
git status
# HEAD detached at 49a7988
# Changes not staged for commit:
#   (use "git add/rm ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       deleted:    .gitignore
#       modified:   server/libraries/Test.pmod
#       modified:   version
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       bin/steam
#       server/libraries/coal.so
#       server/libraries/steamtools.so
#       server/libraries/wiki.so
#       server/libraries/xml.so
#       server/libraries/xslt.so
#       tmp/
no changes added to commit (use "git add" and/or "git commit -a")

you are missing .gitignore, so let's fix that:

git checkout -- .gitignore

run git status; again to see what that did:

# HEAD detached at 49a7988
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:   server/libraries/Test.pmod
#       modified:   version
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       tmp/
no changes added to commit (use "git add" and/or "git commit -a")

most of the untracked files are gone, because they are listed in the .gitignore.

you may or may not see

#       modified:   server/libraries/Test.pmod
#       modified:   version

it depends on how you patched Test.pmod, and on your pike version:
git diff; will show you:

diff --git a/server/libraries/Test.pmod b/server/libraries/Test.pmod
index 4378768..aea5e3a 100644
--- a/server/libraries/Test.pmod
+++ b/server/libraries/Test.pmod
@@ -98,7 +98,7 @@ int start_test ( object|void obj ) {
   if ( suite["started"] == 0 )
     suite["started"] = time();
 
-  object first_test = TestCard( obj, obj->test, 0, 0);
+  object first_test = TestCard( obj, obj->test, 0, 0 );
   suite["pending_calls"] += ({ first_test });
   first_test->enqueue();
   return 1;
diff --git a/version b/version
index 7944427..b32c4b6 100755
--- a/version
+++ b/version
@@ -1 +1 @@
-Pike v7.8 release 700
+Pike v7.8 release 866

i have a newer pike version, and i added an extra space in the patch for Test.pmod

we can fix Test.pmod:

git checkout -- server/libraries/Test.pmod

we'll ignore version for now.

now that we are confident that the installation matches the repository, we can update to the latest development state:

git checkout origin/societyserver-devel -b `hostname`-devel;
git status;
# On branch -devel
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:   version
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       tmp/
no changes added to commit (use "git add" and/or "git commit -a")

there! your server is now up-to-date. you can now track your changes, and send us patches. don't forget to restart.

and we can now use the updated tools to import the REST API.

Author :mbaehr   |   size :4610Bytes   |   Publish Date :Sep/5/15/08:08   |   to Top

these are the commands needed to install sTeam from source on CentOS 6.5

Pike

  yum install mysql-server mysql-devel bzip2-devel libjpeg-devel  libpng-devel zlib-devel pcre-devel freetype-devel gmp-devel make nettle-devel gcc tar
  # in centos 7 install mariadb-server instead
  get the pike source from http://pike.lysator.liu.se
  unpack...
  make
  make install

sTeam

  # get steam 2.9 from git repo
  git clone http://github.com/societyserver/sTeam.git
  cd sTeam
  git checkout steam-2.9-source
  # get webinterface
    https://raw.githubusercontent.com/societyserver/sTeam/steam-packages/web-2_2_17.spm
  # patch line 101 in server/libraries/Test.pmod
  # line should be "object first_test = TestCard( obj, obj->test, 0, 0);"
  yum install libxml2-devel libxslt-devel automake flex
  /etc/init.d/mysqld start
  # centos 7: systemctl enable mariadb; systemctl start mariadb
  # centos 7: patch xslt.c following these instructions
  ./build
  ./install
  # start the server:
  cd /usr/local/lib/steam/
  ./start

  # install the webinterface with the spm tool:
  /usr/local/lib/steam/bin/spm -i web-2_2_17.spm
  
  # login at https://localhost/ (username "root", password "steam")

  # optional: set up your system to start sTeam automatically
  chkconfig --add steam
  chkconfig steam on

at this point you should have a running server

for other linux distributions you may need to adapt the package names, and you may also run into versioning issues with regards to libxml and libxslt. in future versions i intend to remove the libxml/libxslt support. (pike itself has xml support for your development needs. libxml is only needed for libxslt, and i want to remove the latter.)

Author :mbaehr   |   size :2043Bytes   |   Publish Date :Aug/31/15/15:16   |   to Top