====== 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.
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:
* start: Start the EMEN2 web server
* stop: Stop the EMEN2 web server
* restart: Restart the EMEN2 web server
* recover: Run database recovery
emen2ctl also requires an EMEN2 database environment. This may be set using either the "-h" option (e.g. "-h $HOME/test.db") 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" and bind the server to port 8080 (default) with "--port".
bash$ emen2ctl start -h ~/test.db --port 8080
Starting emen2
[INFO] Web server started
This will create a "pid" file in the database environment (in this example, /Users/irees/test.db/log/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 ~/test.db
Stopping emen2 [process 30821]
====== Restart the EMEN2 web server ======
Similar to "start." This will stop the current server process, then restart.
bash$ emen2ctl restart -h ~/test.db
Stopping emen2 [process 30821]
Starting emen2
Removing stale pidfile /Users/irees/test.db/log/emen2.pid
[INFO] Web server started
====== 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 ~/test.db
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]