Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start jar with command : nohup nice java -jar xxxx 2>> /dev/null >> /dev/null & #364

Open
GunleyChan opened this issue Dec 18, 2020 · 0 comments

Comments

@GunleyChan
Copy link

I am using : gradle-ssh-plugin-2.10.1 (groovy-ssh-2.10.1, jsch-0.1.54, groovy-2.5.12, java-11.0.8)

Steps to reproduce

db-function-server.sh:

#!/bin/bash
SERVICE_NAME=db-function-server
WEBAPP_DIR=/data/db-function-server
PATH_JAR=/data/db-function-server/db_function_server.jar
PATH_PID=/opt/db_function_server/db_function_server.pid

function stop {
        if [ -f $PATH_PID ]; then
                        PID=$(cat $PATH_PID)
                        echo "Stopping $SERVICE_NAME ..."
                        kill $PID;
                        echo "Stopped $SERVICE_NAME"
                        rm $PATH_PID
                else
                        echo "$SERVICE_NAME is not running!"
                fi
}

case $1 in
    start)
        if [ -f $PATH_PID ]; then
            stop
        fi
	echo "Starting $SERVICE_NAME ..."
        cd /data/db-function-server
        nohup  java -jar  $PATH_JAR 2>> /dev/null >> /dev/null & 
        echo $! > $PATH_PID
        echo "$SERVICE_NAME started"
    ;;
    stop)
        stop
    ;;
esac
task putJarToSit(dependsOn: build) {

    doLast {
        ssh.run {
            session(remotes.sit) {
                println 'Backup db_function_server.jar'
                println execute("cp -r /data/db-function-server/db_function_server.jar /data/db-function-server/db_function_server.jar.${new Date().format('yyyyMMddHHmmss')}")
                println "Begin File Transfer : ${new Date().format('yyyyMMddHHmmss')}"
                put from: "${System.getProperty("user.dir")}\\build\\libs\\db_function_server.jar", into: '/data/db-function-server/'
                println "End File Transfer  : ${new Date().format('yyyyMMddHHmmss')}"
//                sleep(3 * 1000)
//                println 'Stop db-function-server'
//                execute '/home/avengers/bin/db-function-server.sh stop'
//                println 'db-function-server stopped'
                println 'Start db-function-server server'
                println execute('/home/avengers/bin/db-function-server.sh start')
//                println executeScript('''
//                        #!/bin/bash
//                        SERVICE_NAME=db-function-server
//                        WEBAPP_DIR=/data/db-function-server
//                        PATH_JAR=/data/db-function-server/db_function_server.jar
//                        PATH_PID=/opt/db_function_server/db_function_server.pid
//
//                        function stop {
//                                if [ -f $PATH_PID ]; then
//                                                PID=$(cat $PATH_PID)
//                                                echo "Stopping $SERVICE_NAME ..."
//                                                kill $PID;
//                                                echo "Stopped $SERVICE_NAME"
//                                                rm $PATH_PID
//                                        else
//                                                echo "$SERVICE_NAME is not running!"
//                                        fi
//                        }
//
//                        function start {
//                            if [ -f $PATH_PID ]; then
//                                    stop
//                                fi
//                                echo "Starting $SERVICE_NAME ..."
//                                cd /data/db-function-server
//                                nohup nice java -jar  $PATH_JAR 2>> /dev/null >> /dev/null &
//                                echo $! > $PATH_PID
//                                echo "$SERVICE_NAME started"
//                        }
//
//                        start
//
//                        ''')
//                println executeScript(file('deploy.sh'))
                sleep(5000)
                println 'db-function-server started'
            }
        }
    }

}

Please help. Thanks a lot!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant