#137 Declined
Repository
Branch
ITOPS-373-make-synchrony-a-service
Repository
Branch
master
Author
  1. David Nicholson
Reviewers
Description
  • notes and adding branch to repo to pick up later
  • added testing files and code for startup script, need to separate and remove those files
  • merged testing into init script and began testing functionality, needs further testing on some file ops, just getting code into repo at a stopping point
  • Finished testing, writes synchrony service and runs, allows collab editing, secrets and password removed from command and stored in env file
  • Commit status
  • Issues 2 related issues
  • All tasks resolved
  • Dependencies Checking for dependencies...
  • Dependents Checking for dependents...

Comments (22)

  1. David Nicholson Account Deactivated author

    @deniseunt @bmeehan - changed the cp to cp -rs to make sym links and tested that - it works the same

  2. Brett Meehan

    The following are principles I believe in and try to adhere to :-
    Avoid duplication if at all possible
    Avoid Here Docs in scripts wherever possible
    Avoid hardcoding content which may change due to releases external to this code wherever possible

    I wont be approving a PR that ignores all of these concepts

    1. David Nicholson Account Deactivated author

      Made this inline below but wanted to include in response:

      I think I’m looking at this with having done the work and seeing a bit more of what’s involved. For example I’ve removed 53 lines from the original - a combination of redundant info and comments, though largely the latter, which were removed at your request. That’s another 53 lines.

      Additionally, I’m trying to follow the guidelines set forth for the team:

      • Simpler is better than clever - explicitly writing the file here is simple, straight forward, easy to read, and even easier to update (sed/regex are not simple or common)
      • Align with the design in Public:master - this is also used in the init-10 script, so isn’t something new or outside of the standard convention

      Also, you’d mentioned maintenance. If there are changes to the script, this could break all sed functionality, or require new, which would probably be about the same amount of fixes in either case, though I strongly believe that seeing the whole file here is much easier to read and understand.

      So, given that the difference is ~60 lines vs 79 lines, and the longer format is significantly easier to read, understand, and maintain, I ask that you reconsider your view. Please also consider that you’re frequently frustrated with the time that it takes to complete these tasks, and I don’t think there’s any benefit for me spending another day or more working out how to replace/add/delete lines using sed and regex, then testing, when I have a working solution here that I believe is better for us and our customers as it’s easier to read and maintain.

  3. David Nicholson Account Deactivated author

    @deniseunt Original and final start-synchrony.sh:

    DEFAULT start-synchrony.sh:
    
    #!/bin/bash
    
    # Use this script to start a standalone Synchrony process on Linux (for use with Confluence Data Center only)
    # Replace the <values> below with appropriate values for your environment.
    # For more information about the Synchrony system properties you can configure see:
    # https://confluence.atlassian.com/display/DOC/Configuring+Synchrony+for+Data+Center
    
    # Parse the Synchrony home folder from the script location
    SYNCHRONY_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    
    ################################## Parameters to configure ##################################
    
    # IP address or hostname of this Synchrony node -- should be reachable by other nodes
    SERVER_IP="<SERVER_IP>"
    
    # Your Confluence database information (can be copied from confluence.cfg.xml in your Confluence home directory)
    DATABASE_URL="<YOUR_DATABASE_URL>"
    DATABASE_USER="<DB_USERNAME>"
    
    # We recommend setting your password with the environment variable SYNCHRONY_DATABASE_PASSWORD.
    # This allows Synchrony to detect sensitive information without making it visible in the process command information.
    # However, you may also hardcode your password here.
    DATABASE_PASSWORD="<DB_PASSWORD>"
    
    # # Uncomment this section if you want to do node discovery using TCP/IP
    # # Comma separated list of IP addresses for each cluster node
    # TCPIP_MEMBERS="<TCPIP_MEMBERS>"
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=tcpip \
    # -Dcluster.join.tcpip.members=${TCPIP_MEMBERS}"
    
    # # Uncomment this section if you want to do node discovery in AWS
    # ATL_HAZELCAST_NETWORK_AWS_TAG_KEY="<AWS_TAG_KEY>"
    # ATL_HAZELCAST_NETWORK_AWS_TAG_VALUE="<AWS_TAG_VALUE>"
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=aws \
    # -Dcluster.join.aws.tag.key=${ATL_HAZELCAST_NETWORK_AWS_TAG_KEY} \
    # -Dcluster.join.aws.tag.value=${ATL_HAZELCAST_NETWORK_AWS_TAG_VALUE}"
    
    # # Uncomment this section if you want to do node discovery using multicast
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=multicast"
    
    # Locations of the synchrony-standalone.jar and database driver jar
    DATABASE_DRIVER_PATH="<JDBC_DRIVER_PATH>"
    SYNCHRONY_JAR_PATH="<PATH_TO_SYNCHRONY_STANDALONE_JAR>"
    
    # URL that the browser uses to contact Synchrony -- should include the context path
    SYNCHRONY_URL="<SYNCHRONY_URL>"
    
    # Optionally override default system property values here. Consult docs for more optional properties
    # Example usage: OPTIONAL_OVERRIDES="-Dsynchrony.port=8099 -Dcluster.listen.port=5701"
    OPTIONAL_OVERRIDES=""
    
    # # Uncomment this section if you're running Confluence in an IPv6 environment
    # OPTIONAL_OVERRIDES="${OPTIONAL_OVERRIDES} -Dhazelcast.prefer.ipv4.stack=false"
    
    # # Uncomment this section to specify an executable shell script to source for environment variables
    # # Useful for passing sensitive information (i.e. passwords) to Synchrony
    # # Use this method when setting environment variables for Synchrony running as a service
    # # Example of file contents:
    # #     export SYNCHRONY_DATABASE_USERNAME="<DB_USERNAME>"
    # #     export SYNCHRONY_DATABASE_PASSWORD="<DB_PASSWORD>"
    # SYNCHRONY_ENV_FILE="<PATH_TO_ENV_FILE>"
    
    # Path to file where Synchrony PID will be stored
    # If you change this, you'll also need to set this value in 'stop-synchrony.sh'
    SYNCHRONY_PID_FILE="${SYNCHRONY_HOME}/synchrony.pid"
    
    # Optionally configure JVM
    JAVA_BIN="java"
    JAVA_OPTS="-Xss2048k -Xmx2g"
    
    #############################################################################################
    
    # check for help prompt or if user has tried to run the script without editing it
    if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ -z "${CLUSTER_JOIN_PROPERTIES}" ]; then
        echo "Edit this file to provide Synchrony information on how to run."
        echo "Then simply run 'start-synchrony.sh' or 'start-synchrony.sh -fg' (to run the process in the foreground)"
        echo "For more information about configuring Synchrony, visit https://confluence.atlassian.com/display/DOC/Configuring+Synchrony+for+Data+Center"
        exit
    fi
    
    # don't try to start Synchrony if another process is already running
    if [ ! -z "${SYNCHRONY_PID_FILE}" ] && [ -f "${SYNCHRONY_PID_FILE}" ]; then
        if [ -s "${SYNCHRONY_PID_FILE}" ] && [ -r "${SYNCHRONY_PID_FILE}" ]; then
            PID=`cat ${SYNCHRONY_PID_FILE}`
            if [ ! -z "${PID}" ]; then
                ps -p ${PID} > /dev/null 2>&1
                if [ $? -eq 0 ]; then
                    echo "Synchrony appears to still be running with PID ${PID}. Start aborted."
                    echo "If the following process is not a Synchrony process, remove ${SYNCHRONY_PID_FILE} and try again."
                    ps -f -p $PID
                    exit 1
                fi
            fi
        fi
    
        echo "Please remove ${SYNCHRONY_PID_FILE} and try to start Synchrony again."
        exit 1
    fi
    
    # try to source env file if it exists
    if [ -f "${SYNCHRONY_ENV_FILE}" ]; then
        if [ -x "${SYNCHRONY_ENV_FILE}" ]; then
            source ${SYNCHRONY_ENV_FILE}
        else
            echo "Synchrony environment file ${SYNCHRONY_ENV_FILE} exists, but isn't executable."
            echo "If you want to set Synchrony properties this way, stop Synchrony and adjust the file format accordingly."
        fi
    fi
    
    _RUNJAVA="${JAVA_BIN} ${JAVA_OPTS}"
    SYNCHRONY_OPTS="-classpath ${SYNCHRONY_JAR_PATH}:${DATABASE_DRIVER_PATH}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.service.url=${SYNCHRONY_URL}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.bind=${SERVER_IP}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} ${CLUSTER_JOIN_PROPERTIES}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} ${OPTIONAL_OVERRIDES}"
    
    [ -z "${SYNCHRONY_DATABASE_URL}" ] && SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.database.url=${DATABASE_URL}"
    [ -z "${SYNCHRONY_DATABASE_USERNAME}" ] && SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.database.username=${DATABASE_USER}"
    [ -z "${SYNCHRONY_DATABASE_PASSWORD}" ] && SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.database.password=${DATABASE_PASSWORD}"
    
    if [[ ${@} == *"-fg"* ]]; then
        ${_RUNJAVA} ${SYNCHRONY_OPTS} synchrony.core sql
    else
        echo "To run Synchrony in the foreground, start the server with start-synchrony.sh -fg"
        ${_RUNJAVA} ${SYNCHRONY_OPTS} synchrony.core sql > /dev/null 2>&1 &
    
        # Getting the PID of the process
        PID=$!
        echo $PID > $SYNCHRONY_PID_FILE
        echo "Starting Synchrony with PID ${PID}..."
        echo "Binding: ${SERVER_IP}"
        echo "Please wait 30 seconds, then check this heartbeat URL in your browser for an 'OK': ${SYNCHRONY_URL}/heartbeat"
    fi
    


    [root@ip-10-125-58-4 synchrony]# cat start-synchrony.sh
    
    
    #!/bin/bash
    
    # Use this script to start a standalone Synchrony process on Linux (for use with Confluence Data Center only)
    # Replace the <values> below with appropriate values for your environment.
    # For more information about the Synchrony system properties you can configure see:
    # https://confluence.atlassian.com/display/DOC/Configuring+Synchrony+for+Data+Center
    
    # Parse the Synchrony home folder from the script location
    source /etc/sysconfig/atl
    source /etc/atl
    
    ################################## Parameters to configure ##################################
    SYNCHRONY_HOME="$(dirname $ATL_CONFLUENCE_HOME)/synchrony"
    export JWT_PRIVATE="MIIG/wIBADANBgkqhkiG9w0BAQEFAASCBukwggblAgEAAoIBgQC0ZbE3rHLx8zHE8EtTCBqUOXNIrQ8j38WTZ6fHsJBzXN9bV4GXDm2NSwdYU2NK0Yz2cctJ5dvctlweOZsjgcI50GcnTMTpGHElfqa/SlmKZeN63Do+edjegyK+KDbl8sgfvUk5LphQffzogj2wyF4X06H3LCXPDGht/nE8qlyYOaazHtMjZT1vaih/DgQtZZL4bZsgPN+hJPphjAzNqg3rtdFKGtVcAqXoX0eoutuNAOyZROyux22MmEVJ5lcnRcHFBbenldC5sc1T47L0+7wgPdciVXaujuBWxirdYxz/wqwhJltfyfvrC3T6F3OHmm4esT0lb+4IVvp6WcQXs4yDWMfHjg2a7/maw5DsgBd7CbJxUIQkCTRTUPG/hhDcg5ilE5Yr30YYQSSaWBbeiup1P1P7uhsxwZBVbWUavZukSt/W7+sFitTGSwF3igTypP3o7DMGyBll7IaqAXxHtHt+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VXAKl6F9HqLrbjQDsmUTsrsdtjJhFSeZXJ0XBxQW3p5XQubHNU+Oy9Pu8ID3XIlV2ro7gVsYq3WMc/8KsISZbX8n76wt0+hdzh5puHrE9JW/uCFb6elnEF7OMg1jHx44Nmu/5msOQ7IAXewmycVCEJAk0U1Dxv4YQ3IOYpROWK99GGEEkmlgW3orqdT9T+7obMcGQVW1lGr2bpErf1u/rBYrUxksBd4oE8qT96OwzBsgZZeyGqgF8R7R7fsfPUiNu1ObIi3fIg5ux5sxbnXDNdKpgb9/jh3E8MWdvAgMBAAE="
    
    # IP address or hostname of this Synchrony node -- should be reachable by other nodes
    SERVER_IP="10.125.58.4"
    
    # Your Confluence database information (can be copied from confluence.cfg.xml in your Confluence home directory)
    DATABASE_URL=${ATL_JDBC_URL}
    export SYNCHRONY_DATABASE_USERNAME=${ATL_JDBC_USER}
    
    # We recommend setting your password with the environment variable SYNCHRONY_DATABASE_PASSWORD.
    # This allows Synchrony to detect sensitive information without making it visible in the process command information.
    # However, you may also hardcode your password here.
    export SYNCHRONY_DATABASE_PASSWORD=${ATL_JDBC_PASSWORD}
    
    # # Uncomment this section if you want to do node discovery using TCP/IP
    # # Comma separated list of IP addresses for each cluster node
    # TCPIP_MEMBERS="<TCPIP_MEMBERS>"
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=tcpip \
    # -Dcluster.join.tcpip.members=${TCPIP_MEMBERS}"
    
    # # Uncomment this section if you want to do node discovery in AWS
    # ATL_HAZELCAST_NETWORK_AWS_TAG_KEY="<AWS_TAG_KEY>"
    # ATL_HAZELCAST_NETWORK_AWS_TAG_VALUE="<AWS_TAG_VALUE>"
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=aws \
    # -Dcluster.join.aws.tag.key=${ATL_HAZELCAST_NETWORK_AWS_TAG_KEY} \
    # -Dcluster.join.aws.tag.value=${ATL_HAZELCAST_NETWORK_AWS_TAG_VALUE}"
    
    # # Uncomment this section if you want to do node discovery using multicast
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=multicast"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=dave-sync-dc1b   -Dcluster.join.aws.region=us-east-1"
    
    # Locations of the synchrony-standalone.jar and database driver jar
    DATABASE_DRIVER_PATH="$(ls -t ${ATL_CONFLUENCE_INSTALL_DIR}/confluence/WEB-INF/lib/postgresql*.jar | head -n 1)"
    SYNCHRONY_JAR_PATH="${SYNCHRONY_HOME}/synchrony-standalone.jar"
    
    # URL that the browser uses to contact Synchrony -- should include the context path
    SYNCHRONY_URL="${ATL_SYNCHRONY_SERVICE_URL}"
    
    # Optionally override default system property values here. Consult docs for more optional properties
    # Example usage: OPTIONAL_OVERRIDES="-Dsynchrony.port=8099 -Dcluster.listen.port=5701"
    OPTIONAL_OVERRIDES="-Dsynchrony.service.url=http://dave-sync-dc1b.wpt.atlassian.com/synchrony -Dsynchrony.cluster.bind=10.125.58.4 -Dsynchrony.cluster.impl=hazelcast-btf -Dsynchrony.cluster.base.port=25500 -Dsynchrony.bind=10.125.58.4 -Dcluster.interfaces=10.125.58.4 -Dsynchrony.context.path=/synchrony -Dsynchrony.port=8091 -Dcluster.name=Synchrony-Cluster"
    
    # # Uncomment this section if you're running Confluence in an IPv6 environment
    # OPTIONAL_OVERRIDES="${OPTIONAL_OVERRIDES} -Dhazelcast.prefer.ipv4.stack=false"
    
    # # Uncomment this section to specify an executable shell script to source for environment variables
    # # Useful for passing sensitive information (i.e. passwords) to Synchrony
    # # Use this method when setting environment variables for Synchrony running as a service
    # # Example of file contents:
    # #     export SYNCHRONY_DATABASE_USERNAME=${ATL_JDBC_USER}
    # #     export SYNCHRONY_export SYNCHRONY_DATABASE_PASSWORD=${ATL_JDBC_PASSWORD}
    # SYNCHRONY_ENV_FILE="<PATH_TO_ENV_FILE>"
    
    # Path to file where Synchrony PID will be stored
    # If you change this, you'll also need to set this value in 'stop-synchrony.sh'
    SYNCHRONY_PID_FILE="${SYNCHRONY_HOME}/synchrony.pid"
    
    # Optionally configure JVM
    JAVA_BIN="/opt/atlassian/confluence/jre/bin/java"
    JAVA_OPTS="-Xss2048k -Xmx2g"
    
    #############################################################################################
    
    # check for help prompt or if user has tried to run the script without editing it
    if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ -z "${CLUSTER_JOIN_PROPERTIES}" ]; then
        echo "Edit this file to provide Synchrony information on how to run."
        echo "Then simply run 'start-synchrony.sh' or 'start-synchrony.sh -fg' (to run the process in the foreground)"
        echo "For more information about configuring Synchrony, visit https://confluence.atlassian.com/display/DOC/Configuring+Synchrony+for+Data+Center"
        exit
    fi
    
    # don't try to start Synchrony if another process is already running
    if [ ! -z "${SYNCHRONY_PID_FILE}" ] && [ -f "${SYNCHRONY_PID_FILE}" ]; then
        if [ -s "${SYNCHRONY_PID_FILE}" ] && [ -r "${SYNCHRONY_PID_FILE}" ]; then
            PID=`cat ${SYNCHRONY_PID_FILE}`
            if [ ! -z "${PID}" ]; then
                ps -p ${PID} > /dev/null 2>&1
                if [ $? -eq 0 ]; then
                    echo "Synchrony appears to still be running with PID ${PID}. Start aborted."
                    echo "If the following process is not a Synchrony process, remove ${SYNCHRONY_PID_FILE} and try again."
                    ps -f -p $PID
                    exit 1
                fi
            fi
        fi
    
        echo "Please remove ${SYNCHRONY_PID_FILE} and try to start Synchrony again."
        exit 1
    fi
    
    # try to source env file if it exists
    if [ -f "${SYNCHRONY_ENV_FILE}" ]; then
        if [ -x "${SYNCHRONY_ENV_FILE}" ]; then
            source ${SYNCHRONY_ENV_FILE}
        else
            echo "Synchrony environment file ${SYNCHRONY_ENV_FILE} exists, but isn't executable."
            echo "If you want to set Synchrony properties this way, stop Synchrony and adjust the file format accordingly."
        fi
    fi
    
    _RUNJAVA="${JAVA_BIN} ${JAVA_OPTS}"
    SYNCHRONY_OPTS="-classpath ${SYNCHRONY_JAR_PATH}:${DATABASE_DRIVER_PATH}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.service.url=${SYNCHRONY_URL}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.bind=${SERVER_IP}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} ${CLUSTER_JOIN_PROPERTIES}"
    SYNCHRONY_OPTS="${SYNCHRONY_OPTS} ${OPTIONAL_OVERRIDES}"
    
    [ -z "${SYNCHRONY_DATABASE_URL}" ] && SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.database.url=${DATABASE_URL}"
    [ -z "${SYNCHRONY_DATABASE_USERNAME}" ] && SYNCHRONY_OPTS="${SYNCHRONY_OPTS} -Dsynchrony.database.username=${DATABASE_USER}"
    
    if [[ ${@} == *"-fg"* ]]; then
        ${_RUNJAVA} ${SYNCHRONY_OPTS} synchrony.core sql
    else
        echo "To run Synchrony in the foreground, start the server with start-synchrony.sh -fg"
        ${_RUNJAVA} ${SYNCHRONY_OPTS} synchrony.core sql > /dev/null 2>&1 &
    
        # Getting the PID of the process
        PID=$!
        echo $PID > $SYNCHRONY_PID_FILE
        echo "Starting Synchrony with PID ${PID}..."
        echo "Binding: ${SERVER_IP}"
        echo "Please wait 30 seconds, then check this heartbeat URL in your browser for an 'OK': ${SYNCHRONY_URL}/heartbeat"
    fi
    
    1. Denise Unterwurzacher

      # # export SYNCHRONY_export SYNCHRONY_DATABASE_PASSWORD=${ATL_JDBC_PASSWORD}

      Looks like an issue there ^

  4. Brett Meehan

    My comments all against the particular lines. It’s better now and some of my comments are just my personal opinion. The code is functional as it is, there is just some things that are not optimal

  5. David Nicholson Account Deactivated author

    @deniseunt @bmeehan - tested on existing and new, working as expected with some of Brett’s suggested changes.

  6. Brett Meehan

    good progress, there's a few outstanding bits though so I added tasks to make sure they don't get missed

  7. David Nicholson Account Deactivated author

    @bmeehan Thanks for the tasks, I updated those and it should be all set! My testing using different users had different results, so I was trying to make it work regardless of the user, but it still works the old way as well. It should be good to merge, just looking for approval from you and @deniseunt .

  8. Brett Meehan

    only the one thing outstanding… the delete/readd of the line to be a single replace then i think its good to go

  9. Brett Meehan

    Approving now assuming adequate testing has been done….. All the code enhancements are in i believe.

    1. Denise Unterwurzacher

      Pls don’t merge yet @dnicholson - we need to involve the Confluence Server dev team on this. I am meeting with Brendan next week to discuss this amongst other things.

      1. David Nicholson Account Deactivated author

        Thanks @deniseunt , should I add others as approvers for this?

  10. Denise Unterwurzacher

    Needs some testing done using local Synchrony, now that that’s an option.

    • test local synchrony
  11. Brett Meehan

    ok last issues i can see for this is the error copying the pid file right at the end of the startup :-

    Starting Synchrony with PID 1092...
    + echo 'Binding: 10.125.58.69'
    Binding: 10.125.58.69
    + echo 'Please wait 30 seconds, then check this heartbeat URL in your browser for an '\''OK'\'': http://bamc.wpt.atlassian.com/synchrony/heartbeat'
    Please wait 30 seconds, then check this heartbeat URL in your browser for an 'OK': http://bamc.wpt.atlassian.com/synchrony/heartbeat
    + /opt/atlassian/confluence/jre/bin/java -Xss2048k -Xmx2g -classpath /var/atlassian/application-data/synchrony/synchrony-standalone.jar:/opt/atlassian/confluence/confluence/WEB-INF/lib/postgresql-42.1.1.jar -Dsynchrony.service.url=http://bamc.wpt.atlassian.com/synchrony -Dsynchrony.bind=10.125.58.69 -Dcluster.join.type=aws -Dcluster.join.aws.tag.key=synchrony_service -Dcluster.join.aws.tag.value=bamc -Dcluster.join.aws.region=us-east-1 -Dsynchrony.service.url=http://bamc.wpt.atlassian.com/synchrony -Dsynchrony.cluster.bind=10.125.58.69 -Dsynchrony.cluster.impl=hazelcast-btf -Dsynchrony.cluster.base.port=25500 -Dsynchrony.bind=10.125.58.69 -Dcluster.interfaces=10.125.58.69 -Dsynchrony.context.path=/synchrony -Dsynchrony.port=8091 -Dcluster.name=Synchrony-Cluster -Dsynchrony.database.url=jdbc:postgresql://bamc.czgk2gizgia5.us-east-1.rds.amazonaws.com:5432/confluence synchrony.core sql
    + sudo cp -rs /opt/atlassian/confluence/bin/synchrony/synchrony.pid /var/atlassian/application-data/synchrony
    cp: cannot stat ‘/opt/atlassian/confluence/bin/synchrony/synchrony.pid’: No such file or directory
    + rm -rf /tmp/tmp.Ojp4ZF2gYN
    

    oh and that there is no synchrony user/group created and the process is being run as root instead of synchrony as per :- https://confluence.atlassian.com/confkb/run-synchrony-standalone-as-a-service-on-linux-933081078.html

    1. David Nicholson Account Deactivated author

      Per our initial discussions it was supposed to be run as the confluence user - should it create synchrony users or should I make sure it’s being run as confluence?

  12. Brett Meehan

    found one more thing, some duplicated lines in /var/atlassian/application-data/synchrony/start-synchrony.sh (looks like a sed fail)

    # Parse the Synchrony home folder from the script location
    source /etc/sysconfig/atl
    source /etc/atl
    source /etc/sysconfig/atl
    source /etc/atl
    
    .... and later ....
    
    # # Uncomment this section if you want to do node discovery using multicast
    # CLUSTER_JOIN_PROPERTIES="\
    # -Dcluster.join.type=multicast"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=bamc   -Dcluster.join.aws.region=us-east-1"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=bamc   -Dcluster.join.aws.region=us-east-1"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=bamc   -Dcluster.join.aws.region=us-east-1"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=bamc   -Dcluster.join.aws.region=us-east-1"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=bamc   -Dcluster.join.aws.region=us-east-1"
    CLUSTER_JOIN_PROPERTIES="-Dcluster.join.type=aws   -Dcluster.join.aws.tag.key=synchrony_service   -Dcluster.join.aws.tag.value=bamc   -Dcluster.join.aws.region=us-east-1"
    

    doesnt stop it from working but looks bad

    this may be an artefact of me running atl-init-synchrony multiple times on this node

    1. David Nicholson Account Deactivated author

      This looks like the files weren’t cleaned up between runs, but I’ll go through again and double check.

      1. Brett Meehan

        the logic would be best like :- if line i want in file isn't already in file then do sed to add the line to the file

        but no dramas if this is more effort than it’s worth as, except in debugging circumstance, alt-init-synchrony usually only ever runs once

        1. David Nicholson Account Deactivated author

          I’ll also update the CF how-to to make sure the lines for testing include removing those files, with multiple runs that is the best way to avoid the duplicates