Server Start Stop using screen

  • Hallo,

    some days ago I needed a startup script based on screen. Killing the process on stop (like most of the scripts do) was not a solution. There should be a CTRL+C "keypress" to tell the process "please shutdown".
    With this script you could modify your start and stop events as you need. Currently it is created to manage start and stop of sinusbot (TS3 MusikBot) - feel free to use it as you need :-) (sinusbot post).
    (At your own risk - no guarantee and no support!)

    This script was made out of two ideas of creating a start / stop script:

    How it works:
    (Your could change start and stop behaviour by changing "sudo ..." and "sudo -u ..." lines)

    • Start
      • Create an empty screen session
      • Send to screen: switch to "dir" variable path
      • Send to screen: "cmd" to start the program
    • Stop
      • Sends to screen CTRL+C ('\003') and CTL+D ('\004'\) to stop process and log out from screen session
      • Wait 10 seconds for the process to shut down and close screen session - if it takes more than 10 seconds -> kill the process (had no better idea :( )