Subversion Repositories SmartDukaan

Rev

Rev 301 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/env python

##  Copyright (c) 2007-2008 Facebook
##
##  Licensed under the Apache License, Version 2.0 (the "License");
##  you may not use this file except in compliance with the License.
##  You may obtain a copy of the License at
##
##      http://www.apache.org/licenses/LICENSE-2.0
##
##  Unless required by applicable law or agreed to in writing, software
##  distributed under the License is distributed on an "AS IS" BASIS,
##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##  See the License for the specific language governing permissions and
##  limitations under the License.
##
## See accompanying file LICENSE or visit the Scribe site at:
## http://developers.facebook.com/scribe/

'''scribe_ctrl: A simple script for running and monitoring scribe.'''

import sys
from fb303_scripts import *

# thrift python packages need to be installed
import thrift
from thrift import protocol, transport
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

if (len(sys.argv) > 2):
    port = int(sys.argv[2])
else:
    port = 1463

if (len(sys.argv) > 1):
    retval = fb303_simple_mgmt.service_ctrl(sys.argv[1],
                                            port,
                                            trans_factory = TTransport.TFramedTransportFactory(),
                                            prot_factory = TBinaryProtocol.TBinaryProtocolFactory())
    sys.exit(retval)

else:
    print 'Usage: scribe_ctrl command [port]'
    print '  commands: stop counters status version name alive'
    sys.exit(2)