LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-09-2016, 12:42 PM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 486

Rep: Reputation: 31
Question How to get Minecraft/Terraria servers to activate on-demand via systemd.


So I've playing around with sockets. Thought this sort of thing would work, but doesn't yet.

First I got blocked by the fact that the socket was holding the port open. So then I got the idea... Minecraft and Terraria both have a list page which pings the server. So could use that ping to start things up... and just have the service start/stop the socket... but it's not working.

Does anyone have a good example or way of doing this?

File: cf_minecraft-circut-1.9.socket
Code:
[Unit]
Description=CF Minecraft Server (Circut Test) Socket
PartOf=cf_minecraft-circut-1.9.service

[Socket]
ListenStream=172.29.0.20:25571
Accept=no

[Install]
WantedBy=sockets.target
File: cf_minecraft-circut-1.9.service
Code:
[Unit]
Description=CF Minecraft Server (Circut Test)
Conflicts=shutdown.target
After=network.target cf_minecraft-circut-1.9.socket
Requires=cf_minecraft-circut-1.9.socket
Before=getty.target

[Service]
Type=forking
User=minecraft
WorkingDirectory=/mnt/MineCraft/MineCraft/minecraft-circut-1.9
# /usr/java/latest/bin/java  -d64 -XX:ParallelGCThreads=6 -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M -Xmx2G -Xms1G

ExecStartPre=/usr/bin/sudo /usr/bin/systemctl stop cf_minecraft-circut-1.9.socket

ExecStart=/usr/bin/screen -dmS minecraft-circut-1.9 /usr/java/latest/bin/java  -Xmn128M -Xmx1G -Xms1G -XX:ParallelGCThreads=2 -jar /u2/cf-git/CarterFamily/MC_Servers/minecraft_server.1.9.2.jar nogui 

ExecStopPost=/usr/bin/sudo /usr/bin/systemctl start cf_minecraft-circut-1.9.socket


NonBlocking=true


[Install]
WantedBy=multi-user.target
 
Old 11-11-2016, 09:20 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,861
Blog Entries: 36

Rep: Reputation: 459Reputation: 459Reputation: 459Reputation: 459Reputation: 459
I've been reading up on this. From https://developer.atlassian.com/blog...et-activation/

Quote:
one of its limitations is that it requires the activated application to be aware that it may be socket-activated; the process of accepting an existing socket, while simple, is different from creating a listening socket from scratch.
It's possible minecraft server is not designed to accommodate socket activation in systemd.

That same article goes on to discuss systemd-socket-proxyd which serves as a possible solution for applications that don't support socket activation. I recommend you read that article and the links it references. You may be able to translate that solution to your own.

Last edited by sag47; 11-11-2016 at 09:24 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Systemd on-demand like xinitd/ftp? MikeyCarter Linux - Software 1 06-06-2016 05:35 AM
LXer: Minecraft NFC -- How one man took Minecraft to the next level LXer Syndicated Linux News 0 02-21-2016 05:53 AM
[SOLVED] Launch Minecraft and Minecraft server as non-root user Hasek39 Linux - General 4 01-04-2016 03:06 AM
LXer: GOL MineCraft Weekly. Grab Issue 2 Today, Linux Minecraft server LXer Syndicated Linux News 0 08-04-2013 11:41 AM
LXer: Demand for Linux servers reaches record levels LXer Syndicated Linux News 0 02-22-2006 09:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration