# Configuration update script

The configuration update script defined in the AppConfig.xml document is included in this section, with numbered steps indicating the actions performed at each point in the script.

Note that the script starts by checking if Oracle Endeca Workbench integration is enabled, taking no action (other than logging a message) if disabled.

    <script id="ConfigUpdate">
        <bean-shell-script>
          <![CDATA[
        log.info("Starting dgraph config update script.");
        if (ConfigManager.isWebStudioEnabled()) {

1. Download the Oracle Endeca Workbench Dgraph config files. Download Workbench-maintained configuration files that can be applied to a Dgraph. Remove any files from this set that are not configured to be maintained in Oracle Endeca Workbench in the `ConfigManager` component.

       ConfigManager.downloadWsDgraphConfig();

2. Clean working directories. Clear any files in the local Dgraph configuration directories to which files are distributed on each Dgraph server.

       DgraphCluster.cleanLocalDgraphConfigDirs();

3. Distribute configuration files to each server. A single copy of the Dgraph configuration files is distributed to each server specified in the configuration.

       DgraphCluster.copyDgraphConfigToDgraphServers();

4. Update MDEX Engines. The Dgraph processes are updated. Engines are updated according to the `restartGroup` property specified for each Dgraph. The update process for each Dgraph is as follows:
   1. Copy configuration files into the dgraph_input directory.
   2. Trigger a configuration update in the Dgraph by calling the URL `config?op=update`.
   3. Flush the Dgraph's dynamic cache to ensure the new configuration is applied by calling the URL `admin?op=flush`.
   This somewhat complex update functionality is implemented to minimize the amount of time that a graph is stopped. This restart approach ensures that the graphs are stopped just long enough to rename two directories for each Dgraph.

             DgraphCluster.applyConfigUpdate();
           } else {
             log.warning("Workbench integration is disabled. No action will be taken.");
           }
           log.info("Finished updating dgraph config.");
             ]]>
           </bean-shell-script>
         </script>