Skip to content

Commit

Permalink
Merge pull request #1 from khaledk2/feedback
Browse files Browse the repository at this point in the history
Feedback
  • Loading branch information
khaledk2 authored Apr 15, 2024
2 parents 871fb43 + 55ecce1 commit 1d1c336
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 82 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ OMERO-Server and OMERO-Web are required.
Role Variables
--------------

- ms_user: 'omero-server': icroservice user, the defaults is omero-server
ms_user: 'omero-server'
- ms_folder: Microservice installation folder
- ms_port: Microservice port
- databse_url: Omero Database URL
- db_port: Omero database server port
- db_name: Omero database name
- db_user_name: Omero database user name
- db_pass: 'omero' :Omero database user password
- log_evel: Log level, it can be info, debug or error
- omero_ms_image_region_user: 'omero-server': icroservice user, the defaults is omero-server
omero_ms_image_region_user: 'omero-server'
- omero_ms_image_region_folder: Microservice installation folder
- omero_ms_image_region_port: Microservice port
- omero_ms_image_region_db_url: Omero Database URL
- omero_ms_image_region_db_port: Omero database server port
- omero_ms_image_region_db_name: Omero database name
- omero_ms_image_region_db_username: Omero database user name
- omero_ms_image_region_db_pass: 'omero' :Omero database user password
- omero_ms_image_region_log_level: Log level, it can be info, debug or error
- omero_data_dir: Omero data folder
- omero_script_repo_root: Omero scripts folder
- worker_pool_size: No of Microservice workers, the default is double the number of processors which the machine has
- omero_ms_image_region_ms_worker_pool_size: No of Microservice workers, the default is double the number of processors which the machine has
- session_id: Omero Session id, if you do not know it, you may get it using this command:


/opt/omero/web/OMERO.web/bin/omero config get omero.web.session_cookie_name

- update_nginx: if false, it will not update the nginx config file
- omero_ms_image_region_update_nginx: if false, it will not update the nginx config file

Example Playbook
----------------

- hosts: localhost
roles:
- role: ome.omero_ms_image_region
update_nginx: true
omero_ms_image_region_update_nginx: true
34 changes: 19 additions & 15 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
# defaults for omero_ms_image_region

# Microservice user, the defaults is omero-server
ms_user: 'omero-server'
omero_ms_image_region_user: 'omero-server'

# Microservice installation folder
ms_folder: '/opt/omero/microservice'
omero_ms_image_region_folder: '/opt/omero/microservice'

# Microservice port
ms_port: '8081'
omero_ms_image_region_port: '8081'

# Omero Database URL
databse_url: '127.0.0.1'
omero_ms_image_region_db_url: '127.0.0.1'

# Omero database server port
db_port: '5432'
omero_ms_image_region_db_port: '5432'

# Omero database name
db_name: 'omero'
omero_ms_image_region_db_name: 'omero'

# Omero database user name
db_user_name: 'omero'
omero_ms_image_region_db_username: 'omero'

# Omero database user password
db_pass: 'omero'
omero_ms_image_region_db_pass: 'omero'

# Log level, it can be info, debug or error
log_evel: 'debug'
omero_ms_image_region_log_level: 'debug'

# Omero data folder
omero_data_dir: '/OMERO'
Expand All @@ -35,21 +35,25 @@ omero_data_dir: '/OMERO'
omero_script_repo_root: '/opt/omero/server/OMERO.server/lib/scripts/'

# No of Microservice workers, the default is double the number of processors which the machine has
worker_pool_size: '10'
omero_ms_image_region_ms_worker_pool_size: '10'

# Omero Session id, if you do not know it, you may get it using this command:
# /opt/omero/web/OMERO.web/bin/omero config get omero.web.session_cookie_name
session_id: 'sessionid'
omero_ms_image_region_session_id: 'sessionid'

# This role variable controls updating the nginx config file, omero-web.conf
# if false, it will not update the file
update_nginx: false
omero_ms_image_region_update_nginx: false

# Microservice download URL, you should updated with version which is compatable with your omero-server
# The bio-format version for both the microservice and Omero-Server should be the same
# Also, in case of using ngff data, the version of OMEZarrReader should be the same for both of Microsevice and Omero-Server
download_URL: 'https://github.com/khaledk2/ice-archh-64/releases/download/new_tag/omero-ms-image-region-0.8.7.zip'
omero_ms_image_region_download_URL: 'https://github.com/khaledk2/ice-archh-64/releases/download/new_tag/omero-ms-image-region-0.8.7.zip'

omero_ms_sha256: f984bb78fa81d4fa603387df919d383485944a15a6a762f5c136cf35aefafeaa
omero_ms_image_region_ms_sha256: f984bb78fa81d4fa603387df919d383485944a15a6a762f5c136cf35aefafeaa

ms_name: "{{ download_URL | basename }}"
omero_ms_image_region_ms_name: "{{ omero_ms_image_region_download_URL | basename }}"

omero_ms_image_region_ms_redis_url: 'localhost'
omero_ms_image_region_ms_redis_port: '6379'
omero_ms_image_region_ms_redis_pass: ''
47 changes: 25 additions & 22 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
---
# tasks for omero_ms_image_region


- name: Check that the ms conf exists
become: true
ansible.builtin.stat:
path: "{{ ms_folder }}/{{ ms_name }}"
path: "{{ omero_ms_image_region_folder }}/{{ omero_ms_image_region_ms_name }}"
register: stat_result

- name: display stats
debug:
var: stat_result.stat.exists

- name: Use sha256 to calculate the checksum
become: true
ansible.builtin.stat:
path: "{{ ms_folder }}/{{ ms_name }}"
path: "{{ omero_ms_image_region_folder }}/{{ omero_ms_image_region_ms_name }}"
checksum_algorithm: sha256
register: stat_ssh256

- name: display stats
debug:
var: stat_ssh256.stat.checksum

- import_tasks: pre_tasks.yml
when:
- stat_ssh256.stat.checksum is undefined or omero_ms_sha256 != stat_ssh256.stat.checksum
- stat_ssh256.stat.checksum is undefined or omero_ms_image_region_ms_sha256 != stat_ssh256.stat.checksum
- not stat_result.stat.exists

- name: omero-ms-image-region | set redis uri in protected mode
ansible.builtin.set_fact:
omero_ms_image_region_ms_redis_uri:
"redis://:@{{ omero_ms_image_region_ms_redis_url }}:{{ omero_ms_image_region_ms_redis_port }}/0"
when: not omero_ms_image_region_ms_redis_pass

- name: omero-ms-image-region | set redis uri in not protected mode
ansible.builtin.set_fact:
omero_ms_image_region_ms_redis_uri:
"redis://:{{ omero_ms_image_region_ms_redis_pass }}@{{ omero_ms_image_region_ms_redis_url }}:{{ omero_ms_image_region_ms_redis_port }}/0"
when: omero_ms_image_region_ms_redis_pass

- name: omero-ms-image-region | copy config file
become: true
become_user: "{{ ms_user }}"
become_user: "{{ omero_ms_image_region_user }}"
ansible.builtin.template:
dest: "{{ ms_folder }}/omero-ms-image-region/conf/config.yaml"
dest: "{{ omero_ms_image_region_folder }}/omero-ms-image-region/conf/config.yaml"
src: config.yaml.j2

- name: omero-ms-image-region | copy log config file
become: true
become_user: "{{ ms_user }}"
become_user: "{{ omero_ms_image_region_user }}"
ansible.builtin.template:
dest: "{{ ms_folder }}/omero-ms-image-region/conf/logback.xml"
dest: "{{ omero_ms_image_region_folder }}/omero-ms-image-region/conf/logback.xml"
src: logback.xml.j2

- name: omero-ms-image-region | copy run.sh
become: true
become_user: "{{ ms_user }}"
become_user: "{{ omero_ms_image_region_user }}"
ansible.builtin.template:
dest: "{{ ms_folder }}/omero-ms-image-region/run.sh"
dest: "{{ omero_ms_image_region_folder }}/omero-ms-image-region/run.sh"
src: run.sh.j2
mode: +x

- name: omero-ms-image-region | copy stop.sh
become: true
become_user: "{{ ms_user }}"
become_user: "{{ omero_ms_image_region_user }}"
ansible.builtin.template:
dest: "{{ ms_folder }}/omero-ms-image-region/stop.sh"
dest: "{{ omero_ms_image_region_folder }}/omero-ms-image-region/stop.sh"
src: stop.sh.j2
mode: +x

Expand All @@ -71,7 +74,7 @@
- name: omero-ms-image-region | selinux http_port_t for ms port
become: true
ansible.builtin.seport:
ports: "{{ ms_port }}"
ports: "{{ omero_ms_image_region_port }}"
proto: tcp
setype: http_port_t
state: present
Expand All @@ -80,4 +83,4 @@
when: ansible_facts.selinux.status == 'enabled'

- import_tasks: update_nginx_config.yml
when: update_nginx
when: omero_ms_image_region_update_nginx
16 changes: 8 additions & 8 deletions tasks/pre_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
- name: omero-ms-image-region | create ms folder
become: true
ansible.builtin.file:
path: "{{ ms_folder }}"
path: "{{ omero_ms_image_region_folder }}"
state: directory
mode: 0755

- name: omero-ms-image-region | download omero-ms-image-region
include_role:
name: ome.deploy_archive
vars:
deploy_archive_dest_dir: "{{ ms_folder }}"
deploy_archive_src_url: "{{ download_URL }}"
deploy_archive_sha256: "{{ omero_ms_sha256 }}"
deploy_archive_symlink: "{{ ms_folder }}/omero-ms-image-region"
deploy_archive_dest_dir: "{{ omero_ms_image_region_folder }}"
deploy_archive_src_url: "{{ omero_ms_image_region_download_URL }}"
deploy_archive_sha256: "{{ omero_ms_image_region_ms_sha256 }}"
deploy_archive_symlink: "{{ omero_ms_image_region_folder }}/omero-ms-image-region"
deploy_archive_internal_root: >-
omero-ms-image-region-0.8.7
- name: omero-ms-image-region | chown to ms-user
become: true
ansible.builtin.file:
path: "{{ ms_folder }}"
owner: "{{ ms_user }}"
group: "{{ ms_user }}"
path: "{{ omero_ms_image_region_folder }}"
owner: "{{ omero_ms_image_region_user }}"
group: "{{ omero_ms_image_region_user }}"
state: directory
recurse: true
mode: 0755
21 changes: 9 additions & 12 deletions templates/config.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The port that the microservice will listen on
port: {{ ms_port }}
port: {{ omero_ms_image_region_port }}
# Configuration for request parsing limits
# * https://vertx.io/docs/apidocs/io/vertx/core/http/HttpServerOptions.html#setMaxInitialLineLength-int-
# * https://vertx.io/docs/apidocs/io/vertx/core/http/HttpServerOptions.html#setMaxHeaderSize-int-
Expand All @@ -17,11 +17,11 @@ omero:
# Copy of the OMERO server configuration which will be reused
omero.server:
omero.data.dir: "{{ omero_data_dir }}"
omero.db.host: "{{ databse_url }}"
omero.db.name: "{{ db_name }}"
omero.db.port: "{{ db_port }}"
omero.db.user: "{{ db_user_name }}"
omero.db.pass: "{{ db_pass }}"
omero.db.host: "{{ omero_ms_image_region_db_url }}"
omero.db.name: "{{ omero_ms_image_region_db_name }}"
omero.db.port: "{{ omero_ms_image_region_db_port }}"
omero.db.user: "{{ omero_ms_image_region_db_username }}"
omero.db.pass: "{{ omero_ms_image_region_db_pass }}"
# OMERO_HOME/lib/scripts
omero.script_repo_root: "{{ omero_script_repo_root }}"
omero.pixeldata.max_tile_length: "2048"
Expand All @@ -34,11 +34,11 @@ omero.server:
omero.client.viewer.interpolate_pixels: "true"
# OMERO.web configuration
omero.web:
session_cookie_name: "{{ session_id }}"
session_cookie_name: "{{ omero_ms_image_region_session_id }}"


# Size of the worker pool (defaults to CPUs x 2)
worker_pool_size: {{ worker_pool_size }}
worker_pool_size: {{ omero_ms_image_region_ms_worker_pool_size }}
#
# Configuration for zipkin http tracing
http-tracing:
Expand All @@ -63,10 +63,7 @@ session-store:
# * https://jdbc.postgresql.org/documentation/80/connect.html
# * https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details
# uri: "jdbc:postgresql://localhost:5432/omero_database?user=omero&password=omero"
# For Redis in protected mode
uri: "redis://:@localhost:6379/0"
# For Redis in non-protected mode
# uri: "redis://:password@localhost:6379/0"
uri: "{{ omero_ms_image_region_ms_redis_uri }}"

redis-cache:
#uri: "redis://cf33da71-d81f-42e3-9932-71c82d52de32@localhost:6379/1"
Expand Down
6 changes: 3 additions & 3 deletions templates/logback.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
</encoder>
</appender>

<logger name="com.glencoesoftware.omero.ms" level="{{ log_evel }}"/>
<logger name="com.glencoesoftware.omero.ms" level="{{ omero_ms_image_region_log_level }}"/>
<logger name="loci" level="debug"/><!-- Bio-Formats -->
<logger name="loci.formats.Memoizer" level="{{ log_evel }}"/><!-- Bio-Formats memoizer -->
<logger name="loci.formats.Memoizer" level="{{ omero_ms_image_region_log_level }}"/><!-- Bio-Formats memoizer -->

<root level="{{ log_evel }}">
<root level="{{ omero_ms_image_region_log_level }}">
<appender-ref ref="FILE" />
</root>
</configuration>
7 changes: 3 additions & 4 deletions templates/omero-ms-image-region.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ After=network.service
USER=omero-server
UMask=0002
Type=simple
WorkingDirectory={{ ms_folder }}/omero-ms-image-region
ExecStart={{ ms_folder }}/omero-ms-image-region/run.sh
ExecStop={{ ms_folder }}/omero-ms-image-region/stop.sh
WorkingDirectory={{ omero_ms_image_region_folder }}/omero-ms-image-region
ExecStart={{ omero_ms_image_region_folder }}/omero-ms-image-region/run.sh
ExecStop={{ omero_ms_image_region_folder }}/omero-ms-image-region/stop.sh
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

2 changes: 1 addition & 1 deletion templates/omero-web.conf.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

upstream image_region_backend {
server 127.0.0.1:8081 fail_timeout=0 max_fails=0;
server 127.0.0.1:{{ omero_ms_image_region_port }} fail_timeout=0 max_fails=0;
}

{{ nginx_contents['content'] | b64decode | regex_replace('}$', '') }}
Expand Down
4 changes: 2 additions & 2 deletions templates/run.sh.j2
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#! /bin/bash
sudo -u {{ ms_user }} JAVA_OPTS="-Dlogback.configurationFile=conf/logback.xml" bash bin/omero-ms-image-region
#! /bin/bash
sudo -u {{ omero_ms_image_region_user }} JAVA_OPTS="-Dlogback.configurationFile=conf/logback.xml" bash bin/omero-ms-image-region
4 changes: 2 additions & 2 deletions templates/stop.sh.j2
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#! /bin/bash
sudo kill -9 `ps aux | grep omero-ms-image-regio | awk '{print $2}'`
#! /bin/bash
sudo kill -9 `ps aux | grep omero-ms-image-region | awk '{print $2}'`

0 comments on commit 1d1c336

Please sign in to comment.