def start_service(service_name):
 logging.info(('Starting ' + service_name))
 watch_name = ''
 if (service_name == datastore_upgrade.CASSANDRA_WATCH_NAME):
  cassandra_cmd = ((CASSANDRA_EXECUTABLE + ' -p ') + PID_FILE)
  start_cmd = 'su -c "{0}" cassandra'.format(cassandra_cmd)
  stop_cmd = (('/usr/bin/python2 ' + APPSCALE_HOME) + '/scripts/stop_service.py java cassandra')
  watch_name = datastore_upgrade.CASSANDRA_WATCH_NAME
  ports = [CASSANDRA_PORT]
  match_cmd = cassandra_interface.CASSANDRA_INSTALL_DIR
 if (service_name == datastore_upgrade.ZK_WATCH_NAME):
  zk_server = 'zookeeper-server'
  command = 'service --status-all|grep zookeeper$'
  if (subprocess.call(command, shell=True) == 0):
   zk_server = 'zookeeper'
  start_cmd = (('/usr/sbin/service ' + zk_server) + ' start')
  stop_cmd = (('/usr/sbin/service ' + zk_server) + ' stop')
  watch_name = datastore_upgrade.ZK_WATCH_NAME
  match_cmd = 'org.apache.zookeeper.server.quorum.QuorumPeerMain'
  ports = [zk.DEFAULT_PORT]
 monit_app_configuration.create_config_file(watch_name, start_cmd, stop_cmd, ports, upgrade_flag=True, match_cmd=match_cmd)
 if (not monit_interface.start(watch_name)):
  logging.error(('Monit was unable to start ' + service_name))
  return 1
 else:
  logging.info('Monit configured for {}'.format(service_name))
  return 0

def start_service ( service_name ) : logging . info ( ( 'Starting ' + service_name ) ) watch_name = '' if ( service_name == datastore_upgrade . CASSANDRA_WATCH_NAME ) : cassandra_cmd = ( ( CASSANDRA_EXECUTABLE + ' -p ' ) + PID_FILE ) start_cmd = 'su -c "{0}" cassandra' . format ( cassandra_cmd ) stop_cmd = ( ( '/usr/bin/python2 ' + APPSCALE_HOME ) + '/scripts/stop_service.py java cassandra' ) watch_name = datastore_upgrade . CASSANDRA_WATCH_NAME ports = [ CASSANDRA_PORT ] match_cmd = cassandra_interface . CASSANDRA_INSTALL_DIR if ( service_name == datastore_upgrade . ZK_WATCH_NAME ) : zk_server = 'zookeeper-server' command = 'service --status-all|grep zookeeper$' if ( subprocess . call ( command , shell = True ) == 0 ) : zk_server = 'zookeeper' start_cmd = ( ( '/usr/sbin/service ' + zk_server ) + ' start' ) stop_cmd = ( ( '/usr/sbin/service ' + zk_server ) + ' stop' ) watch_name = datastore_upgrade . ZK_WATCH_NAME match_cmd = 'org.apache.zookeeper.server.quorum.QuorumPeerMain' ports = [ zk . DEFAULT_PORT ] monit_app_configuration . create_config_file ( watch_name , start_cmd , stop_cmd , ports , upgrade_flag = True , match_cmd = match_cmd ) if ( not monit_interface . start ( watch_name ) ) : logging . error ( ( 'Monit was unable to start ' + service_name ) ) return 1 else : logging . info ( 'Monit configured for {}' . format ( service_name ) ) return 0
start openstack service immediately cli example: .