You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@predictionio.apache.org by "Vinay Naik (JIRA)" <ji...@apache.org> on 2018/12/20 09:30:00 UTC

[jira] [Updated] (PIO-200) Improve redeploy script example

     [ https://issues.apache.org/jira/browse/PIO-200?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vinay Naik updated PIO-200:
---------------------------
    Component/s:     (was: Core)

> Improve redeploy script example
> -------------------------------
>
>                 Key: PIO-200
>                 URL: https://issues.apache.org/jira/browse/PIO-200
>             Project: PredictionIO
>          Issue Type: Improvement
>    Affects Versions: 0.13.0
>         Environment: - Version of PredictionIO - apache-predictionio-0.13.0
> - Other components used
>     - hadoop-2.8.2
>     - spark-2.1.2
>     - elasticsearch-5.6.4
>     - hbase-1.3.2
>     - openjdk-8-jdk
>     - Ubuntu 18.04 LTS
>            Reporter: Vinay Naik
>            Priority: Minor
>
> All,
> I have discovered a potential improvement for redeploy-script (predictionio/examples/redeploy-script/redeploy.sh). Details are outlined below.
> *PIO information*
>  - Version of PredictionIO - apache-predictionio-0.13.0
>  - Other components used
>  ** hadoop-2.8.2
>  ** spark-2.1.2
>  ** elasticsearch-5.6.4
>  ** hbase-1.3.2
>  ** openjdk-8-jdk
> *Issue description*
>  The redeploy script provided in examples is crucial for production deployments to fully leverage real-time ingestion of events.
> However, after extended usage I noticed that whilst _pio deploy_ within script successfully undeploys any existing engine instance and binds a new one to the same port; it fails to clear up resources allocated to previous deployment (read as PID continues to linger). Continued usage will lead to lack of memory forcing us to kill stale processes manually.
> *Code example*
> {code:java}
> # Deploy
> DEPLOY_LOG=`mktemp $LOG_DIR/tmp.XXXXXXXXXX`
> $($DEPLOY_COMMAND 1>$DEPLOY_LOG 2>&1) &
> # Check if the engine is up
> sleep 60
> curl $HOSTNAME:$PORT > /dev/null
> RETURN_VAL=$?
> COUNTER=0
> while [[ $RETURN_VAL -ne 0 && $COUNTER -lt 20 ]]; do
> sleep 30
> curl $HOSTNAME:$PORT > /dev/null
> let RETURN_VAL=$?
> let COUNTER=COUNTER+1
> done{code}
> *Expected behaviour*
>  - Deploys new engine instance
>  - Eliminates old process
> *Actual results*
>  - Deploys new engine instance
>  - Retains old process
> *Suggested resolution*
>  This can be easily handled by;
>  - Looking for PID of any existing engine instance
>  - Complete current _pio deploy_ cycle
>  - If PID for previous instance exist, kill process thus releasing resources.
> {code:java}
> # Deploy
> # Get current running instance PID
> PIDBYPORT_COMMAND="lsof -t -i:$PORT"
> DEPLOYEDPORT=$($PIDBYPORT_COMMAND)
> DEPLOY_LOG=`mktemp $LOG_DIR/tmp.XXXXXXXXXX`
> $($DEPLOY_COMMAND 1>$DEPLOY_LOG 2>&1) &
> # Check if the engine is up
> sleep 60
> curl $HOSTNAME:$PORT > /dev/null
> RETURN_VAL=$?
> COUNTER=0
> while [[ $RETURN_VAL -ne 0 && $COUNTER -lt 20 ]]; do
> sleep 30
> curl $HOSTNAME:$PORT > /dev/null
> let RETURN_VAL=$?
> let COUNTER=COUNTER+1
> done
> # Check if the previous engine instance is running
> KILLSD_COMMAND="kill $DEPLOYEDPORT"
> if [ -z "$DEPLOYEDPORT" ]
> then
> printf "\nNo stale PIDs found for port $PORT\n"
> else
> $($KILLSD_COMMAND)
> printf "\nStale PID found as $DEPLOYEDPORT. Resources released.\n"
> fi{code}
> I will create a pull request to that end.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)