Integration examples

From SynchroEdit

Jump to: navigation, search

A set of Perl modules are available which makes it possible to write Perl scripts that interact with SynchroEdit in various ways. There is additionally a "scripts" directory in the extras directory of the development repository, containing, to this date, five command-line scripts which do various things with a SynchroEdit server.

Getting the scripts

If you don't have the bundle at hand, or if you simply want to take a look at the scripts, you can see them here:

Scripted tasks

While the scripts themselves serve as good examples of what you can do with SynchroEdit, they are also useful commands to use in e.g. bash scripts.

Bash scripted "start on reboot"

This is just as much an example of what you can do with cron as it is an example of what you can do with SynchroEdit.

Problem: You have a SynchroEdit server on a linux machine we'll call fido, which you want to ensure is running at all times. The problem is that you are not the maintainer of fido, and you have no way of knowing beforehand whenever it is rebooted. On your SynchroEdit server, you wish to keep the default session persistent.

Solution: Write a bash script that starts SynchroEdit up. Use crontab to add an entry using the @reboot condition to call said bash script.

Description:

First we have to edit the synchroedit.rc file.

  • Locate the startDefault directive and make sure it is set to 1.
  • Do the same for the preserveDefault directive.
  • Do the same for the autoCreateInstance directive.

startDefault tells SynchroEdit to start a session called "default" whenever SynchroEdit boots up. preserveDefault tells SynchroEdit to "keep" the session file (SIDxxx.xhtml) for the default session when it is rebooted. autoCreateInstance tells SynchroEdit to create a blank instance file if none is found.

Now we have to create the bash script. The bash script has to simply start SynchroEdit up.

We'll name the script synchro-boot and put it in /home/you/bin/.

#!/bin/bash
# Reboot script to make sure the group todo is available.
JAVA=/usr/bin/java
SELOCATION=/home/you/se

cd $SELOCATION
$JAVA sserve.Main 1>>/home/you/se/synchroedit.log 2>>/home/you/se/synchroedit.log &

Ensure that the JAVA and SELOCATION values are valid. JAVA should point to the java binary for Sun Java 5, SELOCATION should point at the directory in which the sserve directory is located (within which the .class files are located). In the above example, the directory /home/you/se should contain a sserve directory.

The 1>>/home/you/se/synchroedit.log 2>>/home/you/se/synchroedit.log & part does two things; 1) it redirects all output to the specified file, rather than telling cron about it, and 2) it runs it as a background process. SynchroEdit can be run both as a daemon or as a console.

Now we have to make the script executable, so we do

$ chmod +x /home/you/bin/synchro-boot

Finally, we have to put this into our crontab. You do this using the crontab command with the -e argument. That is:

$ crontab -e

An editor will be loaded in which we put the following:

@reboot /home/you/bin/synchro-boot

At this point, our SynchroEdit server should be running forever (theoretically), no matter how many times fido is rebooted.

Personal tools