EMEN2 control script (emen2ctl)

Similar to Apache's "apachectl" script, EMEN2 includes an "emen2ctl" script. This can be used to start and stop the server and perform some basic administration tasks.

Running emen2ctl

Note: Depending on how you installed EMEN2, emen2ctl may not be in your $PATH. On Linux, using the recommended installation, it will probably be $HOME/Python/bin/emen2ctl. You can either invoke the script using the full path, or add the directory to your path. (Note: on Linux, adding that directory to your path with a high priority may change the default Python interpreter. You may or may not desire this.)

emen2ctl accepts a single command argument and options after that:

bash$ emen2ctl
Usage: /usr/local/bin/emen2ctl {start|stop|restart|recover} [options]

The following commands are defined:

emen2ctl also requires an EMEN2 database environment. This may be set using either the "-h" option (e.g. "-h $HOME/db.test") or by setting the $EMEN2DBHOME environment variable.

All emen2ctl options will be passed to the EMEN2 server. These will usually be used when starting the server: -e to load extensions, and --port to specify a port.

Note: In the future, the extensions to be loaded will be stored in the configuration file and editable using the web interface instead of the "-e" option. For now, specify them on the command line with "-e".

Start the EMEN2 web server

The "start" command will start the EMEN2 web server. In this example, we pass a database environment with "-h", a list of extensions to load with "-e", and bind the server to port 8080 with "--port".

bash$ emen2ctl start -h ~/data/db.test -e default,em,eman2,site --port 8080
Starting emen2
INFO :: Opening Database Environment: /Users/irees/data/db.test

This will create a "pid" file in the database environment (in this example, /Users/irees/data/db.test/applog/emen2.pid). This file will be used to communicate with the server process later.

Stop the EMEN2 web server

Similarly, the "stop" command will attempt to gracefully stop the EMEN2 web server:

bash$ emen2ctl stop -h ~/data/db.test -e default,em,eman2,site
Stopping emen2 [process 30821]

Restart the EMEN2 web server

Similar to "start." This will stop the current server process, then restart.

Run database recovery

If the server or EMEN2 crashes, you will want to run database recovery before restarting. This will clean the underlying Berkeley DB environment, and abort any transactions that were uncommitted.

bash$ emen2ctl recover -h ~/data/db.test -e default,em,eman2,site
Running emen2 database recovery
BDB2526 Finding last valid log LSN: file: 1 offset 650860
BDB1514 Recovery starting from [1][622364]
BDB1518 Recovery complete at Mon Mar 12 05:14:18 2012
BDB1519 Maximum transaction ID 80000075 recovery checkpoint [1][653815]