#NEWLINE# def main( ) : #NEWLINE# #INDENT# configfile = ( sys . argv [ 2 ] if ( len ( sys . argv ) == 3 ) else 'homeserver.yaml' ) #NEWLINE# if ( not os . path . exists ( configfile ) ) : #NEWLINE# #INDENT# sys . stderr . write ( ( "No config file found\nTo generate a config file, run '%s -c %s --generate-config --server-name=<server name>'\n" % ( ' ' . join ( SYNAPSE ) , configfile ) ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# config = yaml . load ( open ( configfile ) ) #NEWLINE# pidfile = config [ 'pid_file' ] #NEWLINE# action = ( sys . argv [ 1 ] if sys . argv [ 1 : ] else 'usage' ) #NEWLINE# if ( action == 'start' ) : #NEWLINE# #INDENT# start ( configfile ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( action == 'stop' ) : #NEWLINE# #INDENT# stop ( config ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( action == 'restart' ) : #NEWLINE# #INDENT# stop ( pidfile ) #NEWLINE# start ( configfile ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sys . stderr . write ( ( 'Usage: %s [start|stop|restart] [configfile]\n' % ( sys . argv [ 0 ] , ) ) ) #NEWLINE# sys . exit ( 1 )