-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from manics/devel
Refactor startup scripts, envvars for all omero parameter
- Loading branch information
Showing
15 changed files
with
199 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python | ||
# 1. Run .omero files from /opt/omero/server/config/ | ||
# 2. Set omero config properties from CONFIG_ envvars | ||
# Variable names should replace "." with "_" and "_" with "__" | ||
# E.g. CONFIG_omero_web_public_enabled=false | ||
|
||
import os | ||
from subprocess import call | ||
from re import sub | ||
|
||
|
||
CONFIG_OMERO = '/opt/omero/server/config/omero-server-config-update.sh' | ||
OMERO = '/opt/omero/server/OMERO.server/bin/omero' | ||
|
||
if os.access(CONFIG_OMERO, os.X_OK): | ||
rc = call([CONFIG_OMERO]) | ||
assert rc == 0 | ||
|
||
for (k, v) in os.environ.iteritems(): | ||
if k.startswith('CONFIG_'): | ||
prop = k[7:] | ||
prop = sub('([^_])_([^_])', r'\1.\2', prop) | ||
prop = sub('__', '_', prop) | ||
value = v | ||
rc = call([OMERO, 'config', 'set', '--', prop, value]) | ||
assert rc == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# 50-config.py or equivalent must be run first to set all omero.db.* | ||
# omero.db.host may require special handling since the default is | ||
# to use `--link postgres:db` | ||
|
||
set -eu | ||
|
||
omero=/opt/omero/server/OMERO.server/bin/omero | ||
omego=/opt/omero/omego/bin/omego | ||
cd /opt/omero/server | ||
|
||
CONFIG_omero_db_host=${CONFIG_omero_db_host:-} | ||
if [ -n "$CONFIG_omero_db_host" ]; then | ||
DBHOST="$CONFIG_omero_db_host" | ||
else | ||
DBHOST=db | ||
$omero config set omero.db.host "$DBHOST" | ||
fi | ||
DBUSER="${CONFIG_omero_db_user:-omero}" | ||
DBNAME="${CONFIG_omero_db_name:-omero}" | ||
DBPASS="${CONFIG_omero_db_pass:-omero}" | ||
ROOTPASS="${ROOTPASS:-omero}" | ||
|
||
export PGPASSWORD="$DBPASS" | ||
|
||
i=0 | ||
while ! psql -h "$DBHOST" -U "$DBUSER" "$DBNAME" >/dev/null 2>&1 < /dev/null; do | ||
i=$(($i+1)) | ||
if [ $i -ge 50 ]; then | ||
echo "$(date) - postgres:5432 still not reachable, giving up" | ||
exit 1 | ||
fi | ||
echo "$(date) - waiting for postgres:5432..." | ||
sleep 1 | ||
done | ||
echo "postgres connection established" | ||
|
||
psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \ | ||
"select * from dbpatch" 2> /dev/null && { | ||
echo "Upgrading database" | ||
$omego db upgrade --serverdir=OMERO.server | ||
} || { | ||
echo "Initialising database" | ||
$omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
omero=/opt/omero/server/OMERO.server/bin/omero | ||
cd /opt/omero/server | ||
echo "Starting OMERO.server" | ||
exec $omero admin start --foreground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
OMERO.server Docker | ||
=================== | ||
|
||
A CentOS 7 based Docker image for OMERO.server. | ||
|
||
|
||
Running the images | ||
------------------ | ||
|
||
To run the Docker images start a postgres DB: | ||
|
||
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres postgres | ||
|
||
Then run OMERO.server passing the database configuration parameters if they differ from the defaults. | ||
This example uses the default `postgres` system database for convenience, in practice you may want to create your own database. | ||
|
||
docker run -d --name omero-server --link postgres:db | ||
-e CONFIG_omero_db_user=postgres \ | ||
-e CONFIG_omero_db_pass=postgres \ | ||
-e CONFIG_omero_db_name=postgres \ | ||
-e ROOTPASS=omero-root-password \ | ||
-p 4063:4063 -p 4064:4064 \ | ||
openmicroscopy/omero-server | ||
|
||
|
||
Configuration variables | ||
----------------------- | ||
|
||
All [OMERO configuration properties](www.openmicroscopy.org/site/support/omero/sysadmins/config.html) can be set be defining environment variables `CONFIG_omero_property_name=`. | ||
Since `.` is not allowed in a variable name `.` must be replaced by `_`, and `_` by `__`, for example | ||
|
||
-e CONFIG_omero_web_public_enabled=false | ||
|
||
|
||
Configuration files | ||
------------------- | ||
|
||
Additional configuration files for OMERO can be provided by mounting files into `/opt/omero/server/config/`. | ||
Files will be loaded with `omero load`. | ||
For example: | ||
|
||
docker run -d -v | ||
/config/extra.omero:/opt/omero/server/config/extra.omero:ro | ||
openmicroscopy/omero-server | ||
|
||
Parameters required for initializing the server such as database configuration *must* be set using environment variables. | ||
|
||
|
||
Default volumes | ||
--------------- | ||
|
||
- `/opt/omero/server/OMERO.server/var`: The OMERO.server `var` directory, including logs | ||
- `/OMERO`: The OMERO data directory | ||
|
||
|
||
Exposed ports | ||
------------- | ||
|
||
- 4063 | ||
- 4064 | ||
|
||
|
||
Example with named volumes | ||
-------------------------- | ||
|
||
docker volume create --name omero-db | ||
docker volume create --name omero-data | ||
|
||
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres | ||
-v omero-db:/var/lib/postgresql/data postgres | ||
docker run -d --name omero-server --link postgres:db | ||
<-e CONFIG_omero_db_ ...> | ||
-v omero-data:/OMERO | ||
-p 4063:4063 -p 4064:4064 openmicroscopy/omero-server | ||
|
||
|
||
Running without links | ||
--------------------- | ||
|
||
As an alternative to running with `--link` the address of the database can be specified using the variable `CONFIG_omero_db_host` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/local/bin/dumb-init /bin/bash | ||
|
||
set -e | ||
|
||
for f in /startup/*; do | ||
if [ -f "$f" -a -x "$f" ]; then | ||
echo "Running $f $@" | ||
"$f" "$@" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.