title: Systemd service using screen: 'No screen session found'
body: <p>I'm trying to setup a minecraft server for my kid and screen is giving me fits.  I've been following <a href="https://teilgedanken.de/Blog/post/setting-up-a-minecraft-server-using-systemd/" rel="nofollow noreferrer">this</a> tutorial and I've already consulted <a href="https://askubuntu.com/questions/861309/screen-needs-mode-777-with-systemd-service">this</a> AskUbuntu answer.  I'm running on Ubuntu 16.04.5 x64.  I have created the following Service file and linked it to /etc/systemd/system/minecraft.service.</p>
  
  <pre><code>[Unit]
  Description=Minecraft Server
  Documentation=
  
  Wants=network.target
  After=network.target
  
  [Service]
  User=minecraft
  Group=minecraft
  Nice=5
  EnvironmentFile=-/var/minecraft/unit.conf
  KillMode=none
  SuccessExitStatus=0 1
  
  ProtectHome=true
  ProtectSystem=full
  PrivateDevices=true
  NoNewPrivileges=true
  PrivateTmp=true
  InaccessibleDirectories=/root /sys /srv -/opt /media -/lost+found
  ReadWriteDirectories=/var/minecraft/server /usr/bin/screen
  WorkingDirectory=/var/minecraft/server
  #ExecStartPre= /usr/bin/screen -dmS Minecraft
  ExecStart= /usr/bin/screen -dm -S Minecraft '/usr/bin/java -Xmx1500M -Xms1024M -jar /var/minecraft/server/craftbukkit-1.13.jar'
  ExecStop=/usr/bin/screen -S minecraft -p 0 -X stuff "stop^M"
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>When I monitor the service startup, I get the following in the journalctl logs:</p>
  
  <pre><code>Aug 05 14:55:41 spigot-1 systemd[1]: Started Minecraft Server.
  Aug 05 14:55:41 spigot-1 screen[9869]: No screen session found.
  </code></pre>
  
  <p>Per the SO post I referenced, I already changed the permissions in /var/run/screen.  This is the current setup:</p>
  
  <pre><code>root@spigot-1:/var/minecraft/server# ls -alR /var/run/screen/
  /var/run/screen/:
  total 0
  drwxrwxrwx  4 root      root       80 Aug  5 14:12 .
  drwxr-xr-x 23 root      root      860 Aug  5 14:11 ..
  drwx------  2 minecraft minecraft  40 Aug  5 14:55 S-minecraft
  drwx------  2 root      root       40 Aug  5 14:50 S-root
  
  /var/run/screen/S-minecraft:
  total 0
  drwx------ 2 minecraft minecraft 40 Aug  5 14:55 .
  drwxrwxrwx 4 root      root      80 Aug  5 14:12 ..
  
  /var/run/screen/S-root:
  total 0
  drwx------ 2 root root 40 Aug  5 14:50 .
  drwxrwxrwx 4 root root 80 Aug  5 14:12 ..
  </code></pre>
  
  <p>** Debug Notes **
  You'll see the commented ExecStartPre command in there... all that happens if I try to start the screen session with that command is I get a second 'No screen session found' error.</p>
  
  <p>I can launch the server from the command line using 'screen -dmS Minecraft [..]' and reattach.  I can do this both as root and as the 'minecraft' user.</p>
  
  <p>Any help would be greatly appreciated</p>