1. Welcome to LilyPad. Download the project, explore the forums, and create your own LilyPad network.


    If you use the software and enjoy it or have a question, or would like to contribute to the future of the software directly or through resources, please sign up and join our little community.

Usage Service files for Linux systems using systemd Service Manager [Fedora]

Discussion in 'Documentation' started by Perry Gilfillan, Mar 19, 2014.

  1. Perry Gilfillan

    Perry Gilfillan New Member

    I have not seen any mention of systemd service files, so I'll document the scripts and service files I use on my Fedora 20 machines.

    First, I use a shell script to start the services in screen. These scripts record the PID of the proxy and connect processes. If we used "Type=forking" in the service files systemd would record the PID of the screen process.

    This is connect.sh
    Code (text):
    #!/bin/bash
    cd /home/mcserver/connect
    screen -DmS GLP-connect -- ./connect &
    pid=$!
    echo $pid > /var/run/MC/golily.connect
    And this is proxy.sh
    Code (text):
    #!/bin/bash
    cd /home/mcserver/proxy
    screen -DmS GLP-proxy -- ./proxy &
    pid=$!
    echo $pid > /var/run/MC/golily.proxy
    I place them in /home/mcserver/proxy, and /home/mcserver/connect respectively. The service files look there for them.

    Make them executable
    Code (text):
    chmod +x /home/mcserver/connect/connect.sh /home/mcserver/proxy/proxy.sh
    DONT try to run them yet! You will need to configure the tempfile daemon to create /var/run/MC on boot.

    Place the service files in /usr/lib/systemd/system/

    This is GLP-connect.service
    Code (text):
    [Unit]
    Description=GoLilyPad Connector
    After=network.target

    # Start the GoLilyPad Connect Service

    [Service]
    ExecStart=/home/mcserver/connect/connect.sh
    WorkingDirectory=/home/mcserver/connect/
    User=mcserver
    StandardOutput=syslog
    Type=simple
    PIDFile=/var/run/MC/golily.connect
     
    And this is GLP-proxy.service
    Code (text):
    [Unit]
    Description=GoLilyPad Proxy Service
    After=network.target

    # Start the GoLilyPad Proxy Service

    [Service]
    ExecStart=/home/mcserver/proxy/proxy.sh
    WorkingDirectory=/home/mcserver/proxy/
    User=mcserver
    StandardOutput=syslog
    Type=simple
    PIDFile=/var/run/MC/golily.proxy
    Before you can start the services you need to configure tmpfiles. Create the file /etc/tmpfiles.d/minecraft.conf, and reload the tmpfiles
    Code (text):
    cat "D /var/run/MC/ 0700 mcserver mcserver" >> /etc/tmpfiles.d/minecraft.conf

    systemd-tmpfiles --create
     
    And now they can be started!
    Code (text):

    systemctl enable GLP-connect.service
    systemctl enable GLP-proxy.service

    systemctl start GLP-connect.service
    systemctl start GLP-proxy.service
    Check for screens, query systemd
    Code (text):
    screen -ls

    systemctl is-active GLP-connect.service
    systemctl is-active GLP-proxy.service
    I hope this will be useful to many! Now go play!
    Last edited: Apr 3, 2014
    • Informative Informative x 1
  2. Coelho

    Coelho Software Engineer Staff Member Administrator Maintainer

  3. Matt

    Matt Forum Moderator & Contributor Staff Member Moderator Contributor

    Really useful :) Moved to the documentation thread.
  4. Perry Gilfillan

    Perry Gilfillan New Member

    I even use my own documentation on occasion! Configuring a new host today and made a few tweaks to this, where I spotted the odd redundant ( and wrong ) code snippet.
    • Like Like x 1
  5. Warthelm

    Warthelm New Member

    Very useful. Helps me a lot, thanks! :)

Share This Page