Differences between revisions 13 and 14
Revision 13 as of 2012-07-31 21:47:44
Size: 2466
Editor: IanRees
Comment:
Revision 14 as of 2013-04-18 06:02:35
Size: 2235
Editor: IanRees
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

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

= Create a system account for EMEN2 =

Running EMEN2 at system boot

For systems that will run EMEN2 continuously, I highly recommend creating a dedicated "emen2" account. This will run EMEN2 using regular user-level permissions instead of as root. Please see your operating system documentation for creating a new account.

Start EMEN2 using init.d

emen2ctl can be run as a traditional "init.d" script, but this is not recommended because it will run with root privileges. You will also have to find a way to pass the "-h" database environment flag. Instead, I recommend starting EMEN2 using crontab as described below.

Start EMEN2 using crontab

Cron is a tool for running commands (jobs) at specified times and intervals and is generally available on unix-like systems. Modern cron implementations also include an "@reboot" setting that will run a job the system is started. Additionally, each user account can usually schedule their own cron jobs using the "crontab" command. This will allow us to have EMEN2 run as under a regular user account (e.g. "emen2") at boot.

bash$ crontab -e

This will open a text editor (usually vi or pico) to edit your cron file. On a typical Linux installation, insert the following line:

@reboot . $HOME/EMAN2/eman2.bashrc; $HOME/EMAN2/Python/bin/emen2ctl start -h $HOME/db.test -e default,em,site

The first argument is "@reboot" that will schedule this job to run whenever the system is booted. The remainder of the line is a command to start EMEN2 using emen2ctl. First, the EMAN2 shell init file is loaded because cron jobs start with a very minimal environment. The second part runs "emen2ctl start" to start the server, passing two arguments:

  • -h $HOME/db.test

This should point to your EMEN2 database environment. Alternatively, you can set the $EMEN2DBHOME environment variable.

  • -e default,em,eman2,site

This specifies the extensions that will be loaded. You could put this in the config.json file.

Note: Currently, on Linux you will need to patch one file. Edit $HOME/EMAN2/Python/bin/twistd and change the first line to the EMAN2 Python interpreter:

 #!/home/emen2/EMAN2/Python/bin/python

I will correct this in future releases.

EMEN2/Startup (last edited 2013-06-27 07:00:57 by IanRees)