# Post-Installation

> License, metadata database access, metadata schema, Apache Spark, smoke tests and Flexter UI setup.

---

Site [llms.txt](/flexter/v2.10/llms.txt)

---

## License Setup

Copy the license file to one of these locations:

```text
# For all users
/etc/flexter/conf/flexter.lic

# For the current user
~/.config/flexter/flexter.lic

# Same directory from which the Flexter command is launched
./flexter.lic
```

## Flexter Metadata Access

Define the access to the metadata database in `flexter.conf`, setting the connection path and the password, in one of these locations:

```text
# For all users
/etc/flexter/conf/flexter.conf

# For the current user
~/.config/flexter/flexter.conf

# Same directory from which the Flexter command is launched
./flexter.conf
```

For example:

```text
metadata {
  path="jdbc:postgresql:x2er"
  user="flex2er"
  password="flexter"
}
```

The full list of settings is described in the [Configuration](https://docs.sonra.io/flexter/v2.10/docs/configuration-and-settings/) section.

## Installing/Updating Flexter Metadata Schema

With the license and the metadata access in place, load the schema into the database:

```bash
flexchma update

# or with explicit connection parameters
flexchma update -m "jdbc:postgresql:[<host>[:port]/]<db>" -M <user> -w <password>
```

## Installing Apache Spark

When Apache Spark is not already available on the system, it can be downloaded with the `download.sh` module, described in detail in [Flexter Modules / download.sh](https://docs.sonra.io/flexter/v2.10/docs/flexter-modules/download-sh/).

The script checks for an existing local Spark installation and downloads the default version if none is found. A specific Spark version can be requested with `-v`, and `-f` forces the switch to it. All options are listed with `-h`.







<ul class="nav nav-tabs" id="tabs-2" role="tablist">
  <li class="nav-item">
      <button class="nav-link active"
          id="tabs-02-00-tab" data-bs-toggle="tab" data-bs-target="#tabs-02-00" role="tab"
          data-td-tp-persist="with root access" aria-controls="tabs-02-00" aria-selected="true">
        With root access
      </button>
    </li><li class="nav-item">
      <button class="nav-link"
          id="tabs-02-01-tab" data-bs-toggle="tab" data-bs-target="#tabs-02-01" role="tab"
          data-td-tp-persist="without root access" aria-controls="tabs-02-01" aria-selected="false">
        Without root access
      </button>
    </li>
</ul>

<div class="tab-content" id="tabs-2-content">
    <div class="tab-body tab-pane fade show active"
        id="tabs-02-00" role="tabpanel" aria-labelled-by="tabs-02-00-tab" tabindex="2">
        <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># default Spark version</span>
</span></span><span class="line"><span class="cl">sudo /usr/share/flexter/sbin/download.sh
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># specific Spark version</span>
</span></span><span class="line"><span class="cl">sudo /usr/share/flexter/sbin/download.sh -v 3.3.4 -f
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># all options</span>
</span></span><span class="line"><span class="cl">sudo /usr/share/flexter/sbin/download.sh -h
</span></span></code></pre></div>
    </div>
    <div class="tab-body tab-pane fade"
        id="tabs-02-01" role="tabpanel" aria-labelled-by="tabs-02-01-tab" tabindex="2">
        <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># default Spark version</span>
</span></span><span class="line"><span class="cl">~/.local/share/flexter/sbin/download.sh
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># specific Spark version</span>
</span></span><span class="line"><span class="cl">~/.local/share/flexter/sbin/download.sh -v 3.3.4 -f
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># all options</span>
</span></span><span class="line"><span class="cl">~/.local/share/flexter/sbin/download.sh -h
</span></span></code></pre></div>
    </div>
</div>


## Smoke Tests

### Checking Versions

Check that the commands execute successfully and report the expected versions:

```bash
flexchma --version
xsd2er --version
xml2er --version
json2er --version
merge2er --version
```

### Checking The Help

Check that the help works and brings the defaults from the right configuration files:

```bash
flexchma --help
xsd2er --help
xml2er --help
json2er --help
merge2er --help
```

### Testing

The packages ship sample files to exercise the whole pipeline. The paths differ between root and non-root installations.







<ul class="nav nav-tabs" id="tabs-3" role="tablist">
  <li class="nav-item">
      <button class="nav-link active"
          id="tabs-03-00-tab" data-bs-toggle="tab" data-bs-target="#tabs-03-00" role="tab"
          data-td-tp-persist="with root access" aria-controls="tabs-03-00" aria-selected="true">
        With root access
      </button>
    </li><li class="nav-item">
      <button class="nav-link"
          id="tabs-03-01-tab" data-bs-toggle="tab" data-bs-target="#tabs-03-01" role="tab"
          data-td-tp-persist="without root access" aria-controls="tabs-03-01" aria-selected="false">
        Without root access
      </button>
    </li>
</ul>

<div class="tab-content" id="tabs-3-content">
    <div class="tab-body tab-pane fade show active"
        id="tabs-03-00" role="tabpanel" aria-labelled-by="tabs-03-00-tab" tabindex="3">
        <p>Check that the files are parsed:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xsd2er -sRF /usr/share/flexter/samples/donut.xsd.gz
</span></span><span class="line"><span class="cl">xml2er -s /usr/share/flexter/samples/donut.xml.gz
</span></span><span class="line"><span class="cl">json2er -s /usr/share/flexter/samples/donut.json.gz
</span></span></code></pre></div><p>Check that Flexter writes metadata. The command prints the origin ID used in the following steps:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-console" data-lang="console"><span class="line"><span class="cl"><span class="gp">$</span> xsd2er -RF -g1 /usr/share/flexter/samples/donut.xsd.gz
</span></span><span class="line"><span class="cl"><span class="go">   origin: &lt;origin_id&gt;
</span></span></span></code></pre></div><p>Check that xml2er loads the metadata:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xml2er -s -x&lt;origin_id&gt; /usr/share/flexter/samples/donut.xml.gz
</span></span></code></pre></div><p>Check that xml2er writes the parsed data:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xml2er -x&lt;origin_id&gt; /usr/share/flexter/samples/donut.xml.gz -o /tmp/flexter_test
</span></span></code></pre></div><p>Check that merge2er processes the files, in place and then to a different path:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">merge2er /tmp/flexter_test
</span></span><span class="line"><span class="cl">merge2er /tmp/flexter_test -o /tmp/flexter_test2
</span></span></code></pre></div>
    </div>
    <div class="tab-body tab-pane fade"
        id="tabs-03-01" role="tabpanel" aria-labelled-by="tabs-03-01-tab" tabindex="3">
        <p>Check that the files are parsed:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xsd2er -sRF ~/.local/share/flexter/samples/donut.xsd.gz
</span></span><span class="line"><span class="cl">xml2er -s ~/.local/share/flexter/samples/donut.xml.gz
</span></span><span class="line"><span class="cl">json2er -s ~/.local/share/flexter/samples/donut.json.gz
</span></span></code></pre></div><p>Check that Flexter writes metadata. The command prints the origin ID used in the following steps:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-console" data-lang="console"><span class="line"><span class="cl"><span class="gp">$</span> xsd2er -RF -g1 ~/.local/share/flexter/samples/donut.xsd.gz
</span></span><span class="line"><span class="cl"><span class="go">   origin: &lt;origin_id&gt;
</span></span></span></code></pre></div><p>Check that xml2er loads the metadata:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xml2er -s -x&lt;origin_id&gt; ~/.local/share/flexter/samples/donut.xml.gz
</span></span></code></pre></div><p>Check that xml2er writes the parsed data:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xml2er -x&lt;origin_id&gt; ~/.local/share/flexter/samples/donut.xml.gz -o /tmp/flexter_test
</span></span></code></pre></div><p>Check that merge2er processes the files, in place and then to a different path:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">merge2er /tmp/flexter_test
</span></span><span class="line"><span class="cl">merge2er /tmp/flexter_test -o /tmp/flexter_test2
</span></span></code></pre></div>
    </div>
</div>


## Flexter UI Setup

### Services

The flexter-ui package installs two systemd services.

**flexterui-backend** serves the API, and also the frontend when the standalone mode is active:

```bash
sudo systemctl <start|stop|restart|status> flexterui-backend
```

**flexterui-frontend** serves the frontend in production mode only:

```bash
sudo systemctl <start|stop|restart|status> flexterui-frontend
```

### Settings

The flexter-ui settings are found in `/usr/share/flexter/flexter-ui/conf` by default.

#### env.json

Switches between `standalone` and `production` mode. Production requires both the backend and the frontend services; standalone only needs the backend.

```json
{
  "env": "standalone"
}
```

#### backend.properties

For the installation, the datasource configuration matters most: it must point to the Flexter metadata database.

```properties
# Server configuration
server.host = 127.0.0.1
server.port = 8081

# Datasource configuration
spring.datasource.url = jdbc:postgresql:x2er?stringtype=unspecified
spring.datasource.username = flex2er
spring.datasource.password = flexter

# Storage for files and logs configuration
storage.path=/tmp
logs.path=/tmp

# Frontend configuration
cors.origins=*
pagination.pageSize = 20
#link.resource-manager=http://localhost:8088
#link.spark-history-server=http://localhost:18080

# security section
storage.enabled = false
cmd.enabled = false

debug=false
logging.path=/usr/share/flexter/flexter-ui/logs/

# Disable the default mappings
spring.resources.add-mappings=false
spring.mvc.throw-exception-if-no-handler-found=true
```

#### config.production.json

For the installation, `apiUrl` matters most: it must point to the server and port where the backend service is running.

```json
{
  "apiUrl" : "http://localhost:9091/v2",
  "disableParameters": true,
  "disableNewWorkflow": true
}
```

### Restart the services

After changing the settings, restart the services for them to take effect:

```bash
sudo systemctl restart flexterui-backend

# only if env.json is set to production mode
sudo systemctl restart flexterui-frontend
```
