mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2024-12-29 02:57:24 +02:00
Added flag for config file
This commit is contained in:
parent
1b6fef4605
commit
8642b771d5
4
Makefile
4
Makefile
@ -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/
|
||||
|
@ -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"]
|
||||
|
@ -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'
|
||||
|
@ -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
|
||||
}
|
||||
|
7
main.go
7
main.go
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user