Differences between revisions 6 and 7
Revision 6 as of 2012-03-12 09:37:29
Size: 2387
Editor: IanRees
Comment:
Revision 7 as of 2012-03-12 09:37:39
Size: 2384
Editor: IanRees
Comment:
Deletions are marked like this. Additions are marked like this.
Line 40: Line 40:

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

Running EMEN2 at system boot

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

Create a system account for EMEN2

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.

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 a regular user ("emen2" account") 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,eman2,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)