Page 1 of 1
Headless server util scripts.[Linux]
Posted: Wed Jul 22, 2015 1:47 am
by ikanreed
So... the last couple days I've been poking around with the headless server.
And I thought it would be nice to start brewing up some utilities for a web interface.
I've got some scripts to monitor the status of a headless server and present the results as a page, and a couple scripts to help parse game log events, (like players joining and leaving). Has anyone else been working on similar things?
Re: Headless server util scripts.[Linux]
Posted: Wed Jul 22, 2015 3:43 am
by NoPantsMcDance
Been trying to motivate myself to make some but everytime I open the log file to start working on parsing it I'm just like nope. Good to see someone is working on it though so us lazy people can continue what we do best lol. If you need someone to help bugtest your scripts or just feedback upload them and I'll run them on my server and take a look.
EDIT: Forgot to ask what language you're scripts are in.
Re: Headless server util scripts.[Linux]
Posted: Wed Jul 22, 2015 9:09 am
by Bisa
I just uploaded my init script (bash) if this could be useful? (but I guess you already have something like this seeing you mentioned you already monitor the status)
https://forums.factorio.com/forum/vie ... 53&t=13874
Re: Headless server util scripts.[Linux]
Posted: Thu Jul 23, 2015 10:00 pm
by ikanreed
I'll be honest, my scripts aren't quite as nice as those, in terms of features.
I'm looking at trying to parse the autosave files sometime(you know, to report status), but they're a tough nut to crack.
My status page is pretty bare bones, but useful for basic monitoring:
http://ikanreed.net/py/factoriostatus.py
http://ikanreed.net/factorio/factoriostatus.py and here's the code for it.
And
here's the program that handles the output to generate the /players file. You have to manually pipe the server output to it for it to do so.
Re: Headless server util scripts.[Linux]
Posted: Thu Jul 23, 2015 10:53 pm
by Oxyd
You can use pgrep facserver instead of ps aux | grep facserver. Advantage in using pgrep instead of ps and grep is that pgrep won't list itself in the output. Which means you can simply check its return status instead of checking the actual text output – useful in scripts in general, not just here.

Re: Headless server util scripts.[Linux]
Posted: Fri Jul 24, 2015 6:44 am
by Bisa
I've put some thought into determining which process of the server is actually running (you can have multiple factorio installs all running on the same physical/virtual server).
If only looking for "fac" you could potentially find processes named "faculty/facility/minecraft-factory"
Have a look at the find_pid() function in my scrip, currently on line
108
I'm using the invocation (defined on line 79) used to start the binary, hoping this is uniq enough to ensure my pid-finding does not pick up any random pids besides the actual server pid. Good luck =)
It's either implementing soemthing similar in your py script or perhaps leave the init script as it is and call "/etc/init.d/factorio status" from your script, if the server is indeed running that will return 0, if it is not it will return 1 per shell scripting convention.