Skip to content

Commit

Permalink
Merge pull request #77 from Bisa/develop
Browse files Browse the repository at this point in the history
added option to retain server.out log
  • Loading branch information
Bisa authored Jul 15, 2016
2 parents 20382e1 + 2ff2c27 commit a8b36c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ AUTOSAVE_INTERVAL=10
# The number of autosaves to use for rotation
AUTOSAVE_SLOTS=3

# Save the command/chat/log on server start? Default location /opt/factorio/server.out
# Setting this to 0 will cause the script to erase the log file on each start
# If you set this to 1 you might want to apply logrotate on the log or it will eventually fill your disk
SAVELOG=0

# Factorio comes packaged in a tarball containing the directory named "factorio"
# when using this scripts update/install command we expect to see this very
# directory. If you want to supply your own update/install tar other than what you can download
Expand Down
11 changes: 10 additions & 1 deletion factorio
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ if ! [ $1 == "install" ]; then
CMDOUT="${WRITE_DIR}/server.out"
fi

if [ -z "${SAVELOG}" ]; then
SAVELOG=0
fi

# Finally, set up the invocation
INVOCATION="${BINARY} --config ${FCONF} --port ${PORT} --start-server-load-latest --server-settings ${SERVER_SETTINGS} --autosave-interval ${AUTOSAVE_INTERVAL} --autosave-slots ${AUTOSAVE_SLOTS} --latency-ms ${LATENCY} ${RCON} ${EXTRA_BINARGS}"

Expand Down Expand Up @@ -164,7 +168,12 @@ start_service() {
return 1
fi

as_user "tail -f ${FIFO} |${INVOCATION} > ${CMDOUT} 2>&1 & echo \$! > ${PIDFILE}"
if [ "${SAVELOG}" == "0" ]; then
debug "Erasing log ${CMDOUT}"
echo "" > ${CMDOUT}
fi

as_user "tail -f ${FIFO} |${INVOCATION} >> ${CMDOUT} 2>&1 & echo \$! > ${PIDFILE}"

ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
Expand Down

0 comments on commit a8b36c2

Please sign in to comment.