コード例 #1
0
ファイル: manager.py プロジェクト: songjundev/b
def exportMongoDb(id):
    print("export mongodb ...")
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    cmd = "~/odin/mongodb/bin/mongodump -h %s -d odin_gamedb_%d -o ./dbdump" %(ip, id)
    print(cmd)
    (status, output) = commands.getstatusoutput(cmd)
    print status, output
コード例 #2
0
ファイル: manager.py プロジェクト: songjundev/b
def updateSconf(id):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading sconf file ...")
    ssh.upload(conn, os.path.abspath(CONFIG_PATH %(id)), UPLOAD_PATH %(id) + "server/sconf.lua")
    ssh.sftpClose(conn)
コード例 #3
0
ファイル: manager.py プロジェクト: songjundev/b
def installMongo(id):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading zip file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.zip"), UPLOAD_ROOT+"/mongodb.zip")

    print("uploading md5 file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.md5"), UPLOAD_ROOT+"/mongodb.md5")

    print("checking md5 ...")
    cmd = "cd %s; md5sum -c %s" %(UPLOAD_ROOT, "./mongodb.md5")
    shell(id, cmd)

    print("creating mongodb folder ...")
    cmd = "mkdir %s/mongodb; mkdir %s/mongodb/bin; mkdir %s/mongodb/data; mkdir %s/mongodb/log; touch %s/mongodb/log/mongodb.log" %(UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT)
    shell(id, cmd)

    print("unziping file ...")
    cmd = "cd %s; unzip -o -d ./mongodb/bin %s" %(UPLOAD_ROOT, "./mongodb.zip")
    shell(id, cmd)

    startMongo(id)

    ssh.sftpClose(conn)
コード例 #4
0
def installMongo(id):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading zip file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.zip"),
               UPLOAD_ROOT + "/mongodb.zip")

    print("uploading md5 file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + "/mongodb.md5"),
               UPLOAD_ROOT + "/mongodb.md5")

    print("checking md5 ...")
    cmd = "cd %s; md5sum -c %s" % (UPLOAD_ROOT, "./mongodb.md5")
    shell(id, cmd)

    print("creating mongodb folder ...")
    cmd = "mkdir %s/mongodb; mkdir %s/mongodb/bin; mkdir %s/mongodb/data; mkdir %s/mongodb/log; touch %s/mongodb/log/mongodb.log" % (
        UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT, UPLOAD_ROOT)
    shell(id, cmd)

    print("unziping file ...")
    cmd = "cd %s; unzip -o -d ./mongodb/bin %s" % (UPLOAD_ROOT,
                                                   "./mongodb.zip")
    shell(id, cmd)

    startMongo(id)

    ssh.sftpClose(conn)
コード例 #5
0
def exportMongoDb(id):
    print("export mongodb ...")
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    cmd = "~/odin/mongodb/bin/mongodump -h %s -d odin_gamedb_%d -o ./dbdump" % (
        ip, id)
    print(cmd)
    (status, output) = commands.getstatusoutput(cmd)
    print status, output
コード例 #6
0
def updateSconf(id):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading sconf file ...")
    ssh.upload(conn, os.path.abspath(CONFIG_PATH % (id)),
               UPLOAD_PATH % (id) + "server/sconf.lua")
    ssh.sftpClose(conn)
コード例 #7
0
ファイル: manager.py プロジェクト: songjundev/b
def initMongo(id):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading mongo init file ...")
    ssh.upload(conn, os.path.abspath(MONGO_INIT_FILE), UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE))

    cmd = "cd %s/mongodb/bin; ./mongo odin_gamedb_%d '%s'" %(UPLOAD_ROOT, id, UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE))
    shell(id, cmd)
    ssh.sftpClose(conn)
コード例 #8
0
ファイル: manager.py プロジェクト: songjundev/b
def updateServers(id, pack):
    if pack == "":
        publish(id, "odin*.tar.gz", UPLOAD_PATH %(id))
    else:
        publish(id, pack, UPLOAD_PATH %(id))

    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading sconf file ...")
    ssh.upload(conn, os.path.abspath(CONFIG_PATH %(id)), UPLOAD_PATH %(id) + "server/sconf.lua")
    ssh.sftpClose(conn)
コード例 #9
0
def initMongo(id):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading mongo init file ...")
    ssh.upload(conn, os.path.abspath(MONGO_INIT_FILE),
               UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE))

    cmd = "cd %s/mongodb/bin; ./mongo odin_gamedb_%d '%s'" % (
        UPLOAD_ROOT, id, UPLOAD_ROOT + os.path.basename(MONGO_INIT_FILE))
    shell(id, cmd)
    ssh.sftpClose(conn)
コード例 #10
0
def updateServers(id, pack):
    if pack == "":
        publish(id, "odin*.tar.gz", UPLOAD_PATH % (id))
    else:
        publish(id, pack, UPLOAD_PATH % (id))

    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    print("uploading sconf file ...")
    ssh.upload(conn, os.path.abspath(CONFIG_PATH % (id)),
               UPLOAD_PATH % (id) + "server/sconf.lua")
    ssh.sftpClose(conn)
コード例 #11
0
ファイル: manager.py プロジェクト: songjundev/b
def publish(id, format, upPath):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    cmd = "cd %s; ls -lt %s | awk '{print $9}' | sed -n '1p;'" %(PACK_PATH, format)
    (status, packFile) = commands.getstatusoutput(cmd)
    packMd5 = packFile + ".md5"
    
    print("uploading zip file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + packFile), upPath + packFile)

    print("uploading md5 file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + packMd5), upPath + packMd5)

    print("checking md5 ...")
    cmd = "cd %s; md5sum -c %s" %(upPath, upPath + packMd5)
    shell(id, cmd)

    print("unziping file ...")
    cmd = "cd %s; tar -zxvf %s" %(upPath, upPath + packFile)
    shell(id, cmd)

    ssh.sftpClose(conn)
コード例 #12
0
def publish(id, format, upPath):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sftpConnect(ip, port, usr, psd)

    cmd = "cd %s; ls -lt %s | awk '{print $9}' | sed -n '1p;'" % (PACK_PATH,
                                                                  format)
    (status, packFile) = commands.getstatusoutput(cmd)
    packMd5 = packFile + ".md5"

    print("uploading zip file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + packFile), upPath + packFile)

    print("uploading md5 file ...")
    ssh.upload(conn, os.path.abspath(PACK_PATH + packMd5), upPath + packMd5)

    print("checking md5 ...")
    cmd = "cd %s; md5sum -c %s" % (upPath, upPath + packMd5)
    shell(id, cmd)

    print("unziping file ...")
    cmd = "cd %s; tar -zxvf %s" % (upPath, upPath + packFile)
    shell(id, cmd)

    ssh.sftpClose(conn)
コード例 #13
0
ファイル: manager.py プロジェクト: songjundev/b
def shell(id, cmd):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sshConnect(ip, port, usr, psd)
    output = ssh.doCommand(conn, cmd)
    ssh.sshClose(conn)
    return output
コード例 #14
0
ファイル: manager.py プロジェクト: songjundev/b
def startMongo(id):
    print("starting mongo ...")
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    cmd = "cd %s/mongodb/bin; chmod 777 *; ./mongod --dbpath=../data/ --logpath=../log/mongodb.log --logappend --smallfiles --profile=1 --slowms=10&" %(UPLOAD_ROOT)
    shell(id, cmd)
コード例 #15
0
def shell(id, cmd):
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    conn = ssh.sshConnect(ip, port, usr, psd)
    output = ssh.doCommand(conn, cmd)
    ssh.sshClose(conn)
    return output
コード例 #16
0
def startMongo(id):
    print("starting mongo ...")
    ip, port, usr, psd = servers.getServer(id, servers.loadData(SERVERS_FILE))
    cmd = "cd %s/mongodb/bin; chmod 777 *; ./mongod --dbpath=../data/ --logpath=../log/mongodb.log --logappend --smallfiles --profile=1 --slowms=10&" % (
        UPLOAD_ROOT)
    shell(id, cmd)