Added flag for config file

This commit is contained in:
majormjr 2016-05-03 11:56:06 -04:00
parent 1b6fef4605
commit 8642b771d5
6 changed files with 12 additions and 8 deletions

View File

@ -2,5 +2,5 @@
#
build:
go build -o $(HOME)/factorio-server-manager/factorio-server-manager
cp -r app/ $(HOME)/factorio-server-manager/
go build -o $(HOME)/factorio-server/factorio-server-manager
cp -r app/ $(HOME)/factorio-server/

View File

@ -25,8 +25,6 @@ RUN curl -s -L -S -k https://www.factorio.com/get-download/$FACTORIO_VERSION/hea
mkdir -p /var/lib/nginx/tmp && \
chown nginx:root /var/lib/nginx
ADD "conf.json" "/opt/factorio-server/conf.json"
EXPOSE 80/tcp 443/tcp 34190-34200/udp
ENTRYPOINT ["/opt/init.sh"]

View File

@ -27,6 +27,6 @@ if [ ! -f /security/passwords.conf ]; then
echo -n "admin:" >> /security/passwords.conf
openssl passwd -apr1 $ADMIN_PASSWORD >> /security/passwords.conf
fi
ls -R /opt/factorio-server
nohup nginx &
/opt/factorio-server/factorio-server-manager -dir '/opt/factorio' -conf '/opt/factorio-server/conf.json'

View File

@ -462,6 +462,7 @@ func StartServer(w http.ResponseWriter, r *http.Request) {
// Check if savefile was submitted with request to start server.
if FactorioServ.Savefile == "" {
log.Printf("Error starting Factorio server: %s", err)
resp.Success = false
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
if err := json.NewEncoder(w).Encode(resp); err != nil {
log.Printf("Error encoding config file JSON reponse: ", err)
@ -475,7 +476,7 @@ func StartServer(w http.ResponseWriter, r *http.Request) {
log.Printf("Error starting Factorio server: %s", err)
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
if err := json.NewEncoder(w).Encode(resp); err != nil {
log.Printf("Error encoding config file JSON reponse: ", err)
log.Printf("Error encoding start server JSON reponse: ", err)
}
return
}

View File

@ -22,6 +22,7 @@ type Config struct {
Username string `json:"username"`
Password string `json:"password"`
DatabaseFile string `json:"database_file"`
ConfFile string
}
var (
@ -72,10 +73,14 @@ func parseFlags() {
}
func main() {
loadServerConfig("./conf.json")
confFile := flag.String("conf", "./conf.json", "Specify location of Factorio Server Manager config file.")
config.ConfFile = *confFile
loadServerConfig(config.ConfFile)
// Initialize Factorio Server struct
FactorioServ = initFactorio()
// Initialize authentication system
Auth = initAuth()
Auth.createAuthDb(config.DatabaseFile)
Auth.createRoles()

View File

@ -17,7 +17,7 @@ type FactorioServer struct {
AutosaveSlots int `json:"autosave_slots"`
Port int `json:"port"`
DisallowCmd bool `json:"disallow_cmd"`
Running bool `json:"bool"`
Running bool `json:"running"`
PeerToPeer bool `json:"peer2peer"`
AutoPause bool `json:"auto_pause"`
StdOut io.ReadCloser