1. When making a thread, please tag your thread accordingly using the menu to the left of the textfield where you name your thread where applicable. Server Advertisements and Mod Releases should be contained to their respective subforums.

Server Discussion StarryPy - A plugin driven server wrapper written in Python.

Discussion in 'Multiplayer' started by Carrots Are Mediocre, Jan 29, 2014.

  1. FuzzyThor

    FuzzyThor Existential Complex

    Is this under windows or linux b/c if its windows you need double \\ with each \\ since you mentioned bat file as apposed to linux's sh file
     
  2. FuzzyThor

    FuzzyThor Existential Complex

    If its ur only python installation you should only need to use python server.py
     
    Last edited: Mar 8, 2014
  3. SweFox

    SweFox Guest

    Oh, so ..\\..\\win32\\killstarbound.bat ?
     
  4. FuzzyThor

    FuzzyThor Existential Complex

    Yea thats how json works just like you direct the config.json to the starbound directory that same goes for that
    Well for windows anyhow
     
  5. mattmonkey24

    mattmonkey24 Void-Bound Voyager

    I have python 2.7 installed but purely for StarryPy 1.x so ill uninstall that when I get home from work
     
  6. FuzzyThor

    FuzzyThor Existential Complex

    Yes the new version of python should be backwards compatible.
    Having more then one version is redundant and would cause errors as it would not know what one to look for making it conflict
     
  7. Fatmice

    Fatmice Subatomic Cosmonaut

    I wanted to share how I spawn Starbound and starrPy1.3.2 on Windows 7 Enterprise.

    I use gawk from GNUWin32 for parsing. You can find it here. Once installed, make sure that you can call awk or gawk from cmd. If you can not, then you need to add the path to GNUWin32\bin to the variable PATH of Environmental variables.

    The rest will be code you can use yourself with a bit of tweaking.

    =================================
    Batch file to spawn Starbound and StarrPy. StarrPy will spawn 90s after the start of script.
    • The first two rem allow toggling of the script so that you can hot fix things. Remove rem to disable and retype rem to enable.
    • Copy and past the path to Starbound and StarrPy to the next two variables: StarboundPath, StarrPyPath.
    • Save as a batch file. Ex: Starbound-Spawner.bat
    • Double-click the batch file to make sure it is working.
    Code:
    @ echo off
    
    rem set Toggle_Starbound_Serv=off
    rem set Toggle_StarrPy_Serv=off
    
    set StarboundPath="C:\starbound_win\starbound_server"
    set StarrPyPath="C:\starbound_win\starbound_server\StarryPy-master"
    
    for /f "tokens=*" %%i in ('tasklist /v /fo list /fi "imagename eq starbound*" ^| findstr /i /r "Image" ^| awk "{if($3 ~ /starbound_server.exe/) a=1; else a=0} END {print a}"') do (set Toggle_Starbound_Serv=%%i)
    
    for /f "tokens=*" %%i in ('tasklist /v /fo list /fi "windowtitle eq starrpy*" ^| findstr /i /r "Window" ^| awk "{if($3 ~ /StarrPy.py/) b=1; else b=0} END {print b}"') do (set Toggle_StarrPy_Serv=%%i)
    
    
    IF "%Toggle_Starbound_Serv%" == "" (
    
       del "%StarboundPath%\starbound_server.log"
       start "Starbound" /d "%StarboundPath%\win32" starbound_server.exe
       timeout /T 90 /NOBREAK >nul
    ) ELSE (
    
       echo "Starbound is running"
    )
    
    IF "%Toggle_StarrPy_Serv%" == "" (
    
       del "%StarrPyPath%\debug.log"
       del "%StarrPyPath%\server.log"
       start "StarrPy.py" /d "%StarrPyPath%" python server.py
    ) ELSE (
    
       echo "StarrPy is running"
    )
    =================================

    I use Win 7 Task Scheduler to watch Starbound and StarrPy. Below are xml files that you can import directly into Task Scheduler. One kills both Starbound and StarrPy at a certain time of the day and the other checks for running process every 5 min.
    • Copy and save to separate files both the XML code below.
    • Change all instances of
      Code:
      <Author>moo-PC\moo</Author>
      <UserId>moo-PC\moo</UserId> 
      to your PC-name\Username
    • Change
      Code:
      <Command>C:\Users\moo\Desktop\Starbound-Spawner.bat</Command>
      to the path of batch file used to start Starbound and StarrPy. In this example path to Starbound-Spawner.bat
    • Import the XMLs into Task Scheduler and enable them.
    • Either restart the computer or relog and they should start working.

    =================================
    Task killer. Copy and save as xml file. Ex: Starbound-Kills.xml
    Code:
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
      <Date>2014-01-30T10:31:59.0167981</Date>
      <Author>moo-PC\moo</Author>
      <Description>Force restart Starbound Server and StarrPy login wrapper</Description>
      </RegistrationInfo>
      <Triggers>
      <CalendarTrigger>
      <StartBoundary>2014-01-31T04:58:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
      <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
      </CalendarTrigger>
      </Triggers>
      <Principals>
      <Principal id="Author">
      <UserId>moo-PC\moo</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
      </Principal>
      </Principals>
      <Settings>
      <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
      <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
      <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
      <AllowHardTerminate>true</AllowHardTerminate>
      <StartWhenAvailable>false</StartWhenAvailable>
      <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
      <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
      </IdleSettings>
      <AllowStartOnDemand>true</AllowStartOnDemand>
      <Enabled>true</Enabled>
      <Hidden>false</Hidden>
      <RunOnlyIfIdle>false</RunOnlyIfIdle>
      <WakeToRun>false</WakeToRun>
      <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
      <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
      <Exec>
      <Command>C:\Windows\System32\taskkill.exe</Command>
      <Arguments>/F /IM "starbound_server.exe"</Arguments>
      </Exec>
      <Exec>
      <Command>C:\Windows\System32\taskkill.exe</Command>
      <Arguments>/F /IM "python.exe"</Arguments>
      </Exec>
      </Actions>
    </Task>
    
    =================================
    Task Spawner. Copy and save as xml file. Ex: Starbound-Spawner.xml
    Code:
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
      <Date>2014-01-30T10:33:50.5446518</Date>
      <Author>moo-PC\moo</Author>
      <Description>Spawn Starbound server and StarrPy login wrapper</Description>
      </RegistrationInfo>
      <Triggers>
      <LogonTrigger>
      <Repetition>
      <Interval>PT5M</Interval>
      <StopAtDurationEnd>false</StopAtDurationEnd>
      </Repetition>
      <Enabled>true</Enabled>
      <UserId>moo-PC\moo</UserId>
      </LogonTrigger>
      </Triggers>
      <Principals>
      <Principal id="Author">
      <UserId>moo-PC\moo</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
      </Principal>
      </Principals>
      <Settings>
      <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
      <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
      <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
      <AllowHardTerminate>true</AllowHardTerminate>
      <StartWhenAvailable>false</StartWhenAvailable>
      <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
      <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
      </IdleSettings>
      <AllowStartOnDemand>true</AllowStartOnDemand>
      <Enabled>true</Enabled>
      <Hidden>false</Hidden>
      <RunOnlyIfIdle>false</RunOnlyIfIdle>
      <WakeToRun>false</WakeToRun>
      <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
      <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
      <Exec>
      <Command>C:\Users\moo\Desktop\Starbound-Spawner.bat</Command>
      </Exec>
      </Actions>
    </Task>
    
    I think SweFox you asked for something similar awhile ago. Maybe you can use this.
     
    Last edited: Mar 8, 2014
  8. FuzzyThor

    FuzzyThor Existential Complex

    what do you use for a starrypy kill script.
    I have killtask python.exe but is does not terminate
     
  9. SweFox

    SweFox Guest

    Just a simple kill command due to the fact that I use FireDaemon for monitoring the process.
     
  10. FuzzyThor

    FuzzyThor Existential Complex

    I think if i just have the script kill cmd.exe that should work
     
  11. SweFox

    SweFox Guest

    But then it will kill starrypy.
     
  12. FuzzyThor

    FuzzyThor Existential Complex

    Other then this error
    'awk' is not recognized as an internal or external command,
    operable program or batch file.
    It works great.
    I installed Gawk.
    Just windows 7 pro
     
  13. FuzzyThor

    FuzzyThor Existential Complex

    I am now using this as my restart script for the web gui
    Code:
    @[USER=7469]Echo[/USER] off
    C:\Windows\System32\taskkill.exe /F /IM "starbound_server.exe"
    C:\Windows\System32\taskkill.exe /F /IM "python.exe"
    cd N:\Servers\Starbound\win32
    start starbound_server.exe
    cd N:\Servers
    start starrypy.bat
     
  14. SweFox

    SweFox Guest

    Oh neat!
     
  15. Fatmice

    Fatmice Subatomic Cosmonaut

    You might want to add a space between @ and echo for purposes of showing batch script. This forum translate the @ when adjacent to a string as it thinks that's a username.

    Also, if gawk or awk is not working when you call it from cmd, make sure they are in the PATH. I think only GNUWin32 will include both awk and gawk.
     
  16. FuzzyThor

    FuzzyThor Existential Complex

    I keep seeing this error on the webgui.log when i try to send a msg. The msg does not get sent to the game but all of the msgs from the game are staying in the correct order also the chat box is scrolling with the text.
    Code:
    Uncaught exception in /chat
    Traceback (most recent call last):
      File "C:\Python27\lib\site-packages\tornado\websocket.py", line 322, in wrapper
        return callback(*args, **kwargs)
      File "N:\Servers\StarryPy\plugins\web_gui\web_gui.py", line 240, in on_message
        d=datetime.now().strftime("%H:%M"), u=self.web_gui_user.name, m=messagejson["message"]), 0, "")
    AttributeError: 'NoneType' object has no attribute 'name'
    Also seems like the restart script button no longer works

    Code:
    Uncaught exception GET /restart (76.102.191.124)
    HTTPRequest(protocol='http', host='sb.fuzzyfrontier.com:8083', method='GET', uri='/restart', version='HTTP/1.1', remote_ip='76.102.191.124', headers={'Accept-Language': 'en-US,en;q=0.8', 'Accept-Encoding': 'gzip,deflate,sdch', 'Host': 'sb.fuzzyfrontier.com:8083', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36', 'Connection': 'keep-alive', 'Referer': 'http://sb.fuzzyfrontier.com:8083/index.html', 'Cookie': 'player=RnV6enlOYW5v|1394167070|5e3c8692e87af45b223c2fdecf325f33e11dbc11; _ga=GA1.2.1514983831.1392333403; __utma=206083972.1514983831.1392333403.1394235975.1394250717.55; __utmb=206083972.4.10.1394250717; __utmc=206083972; __utmz=206083972.1393887998.51.12.utmcsr=community.playstarbound.com|utmccn=(referral)|utmcmd=referral|utmcct=/index.php; bp-activity-oldestpage=1; _ga=GA1.3.1514983831.1392333403; __utma=206622929.1514983831.1392333403.1394164368.1394250986.41; __utmb=206622929.1.10.1394250986; __utmc=206622929; __utmz=206622929.1394250986.41.17.utmcsr=fuzzyfrontier.com|utmccn=(referral)|utmcmd=referral|utmcct=/', 'If-None-Match': '"613e03a2622a1e2b93001a7110c602d50d5896f1"'})
    Traceback (most recent call last):
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1192, in _stack_context_handle_exception
        raise_exc_info((type, value, traceback))
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1375, in wrapper
        result = method(self, *args, **kwargs)
      File "N:\Servers\StarryPy\plugins\web_gui\web_gui.py", line 54, in get
        subprocess.call(self.settings.get("restart_script"), shell=True)
      File "C:\Python27\lib\subprocess.py", line 524, in call
        return Popen(*popenargs, **kwargs).wait()
      File "C:\Python27\lib\subprocess.py", line 711, in __init__
        errread, errwrite)
      File "C:\Python27\lib\subprocess.py", line 907, in _execute_child
        args = list2cmdline(args)
      File "C:\Python27\lib\subprocess.py", line 611, in list2cmdline
        for arg in seq:
    TypeError: 'NoneType' object is not iterable
     
    Last edited: Mar 8, 2014
  17. FuzzyThor

    FuzzyThor Existential Complex

    This was a copy paste error with the starbound forum
    @ Echo off
    C:\Windows\System32\taskkill.exe /F /IM "starbound_server.exe"
    C:\Windows\System32\taskkill.exe /F /IM "python.exe"
    cd N:\Servers\Starbound\win32
    start starbound_server.exe
    cd N:\Servers
    start starrypy.bat

    so should i change
    Code:
    for /f "tokens=*" %%i in ('tasklist /v /fo list /fi "imagename eq starbound*" ^| findstr /i /r "Image" ^| awk "{if($3 ~ /starbound_server.exe/) a=1; else a=0} END {print a}"') do (set Toggle_Starbound_Serv=%%i)
    to
    Code:
    for /f "tokens=*" %%i in ('tasklist /v /fo list /fi "imagename eq starbound*" ^| findstr /i /r "Image" ^| C:\Program Files (x86)\GnuWin32\bin\awk.exe "{if($3 ~ /starbound_server.exe/) a=1; else a=0} END {print a}"') do (set Toggle_Starbound_Serv=%%i)
     
    Last edited: Mar 8, 2014
  18. SweFox

    SweFox Guest

    Is it possible for you to make the chat auto-update?
     
  19. Fatmice

    Fatmice Subatomic Cosmonaut

    Yeah that should work.
     
  20. mattmonkey24

    mattmonkey24 Void-Bound Voyager

    @FuzzyThor i've done "apt-get remove python2.7" and still got
    root@debian-server:/home/starbound/server/StarryPy3k# python server.py
    File "server.py", line 35
    self._client_writer) = yield from asyncio.open_connection("127.0.0.1",
    then i did "apt-get remove python3" but i still get the same error above
     

Share This Page