def restart(app, args):
    app.check()
    if not os.path.exists(app.pid_path()):
        print "~ Oops! %s is not started (server.pid not found)" % os.path.normpath(app.path)
        print "~"
    else:
        pid = open(app.pid_path()).readline().strip()
        os.remove(app.pid_path())
        kill(pid)

    sysout = app.readConf('application.log.system.out')
    sysout = sysout!='false' and sysout!='off'
    java_cmd = app.java_cmd(args)
    if not sysout:
      sout = None
    else:
      sout = open(os.path.join(app.log_path(), 'system.out'), 'w')
    try:
        pid = subprocess.Popen(java_cmd, stdout=sout, env=os.environ).pid
    except __HOLE__:
        print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). "
        sys.exit(-1)
    print "~ OK, %s is restarted" % os.path.normpath(app.path)
    if sysout:
      print "~ output is redirected to %s" % os.path.normpath(os.path.join(app.log_path(), 'system.out'))
    pid_file = open(app.pid_path(), 'w')
    pid_file.write(str(pid))
    print "~ New pid is %s" % pid
    print "~"
    sys.exit(0)
dataset/ETHPy150Open eBay/restcommander/play-1.2.4/framework/pym/play/commands/daemon.py/restart