maxsupermanhd / FactoCord-3.0

Factorio bidirectional Discord bridge bot for Linux servers with control functionality.
Apache License 2.0
14 stars 10 forks source link

Help running as a service on ubuntu #8

Closed szentigrad3 closed 4 years ago

szentigrad3 commented 4 years ago

so i am trying to setup this a service on ubuntu but get this error > 2020-04-11 08:40:59.192088181 +0000 UTC m=+0.006642289: An error occurred when attempting to read the input to pass as input to the console Details: EOF

from my services file > [Unit] Description=Factorio1 Server service After=network.target

[Service] User=noidea WorkingDirectory=/home/noidea/FactoCord-1 ExecStart=/home/noidea/FactoCord-1/FactoCord-1 Restart=always

[Install] WantedBy=multi-user.target

TechnoStrife commented 4 years ago

I guess it wasn't designed to run as servece and therefore tries to read from console

maxsupermanhd commented 4 years ago

Please post full logs of your run.

szentigrad3 commented 4 years ago

Apr 11 12:23:06 exothermic systemd[1]: Started Factorio1 Server service. Apr 11 12:23:06 exothermic FactoCord-1[1476]: Welcome to FactoCord-3.0! Apr 11 12:23:06 exothermic FactoCord-1[1476]: Starting bot.. Apr 11 12:23:06 exothermic FactoCord-1[1476]: Opps, it looks like an error happened! Apr 11 12:23:06 exothermic FactoCord-1[1476]: Please post your error.log on https://github.com/maxsupermanhd/FactoCord-3.0/issues Apr 11 12:23:06 exothermic systemd[1]: factorio1.service: Main process exited, code=exited, status=1/FAILURE Apr 11 12:23:06 exothermic systemd[1]: factorio1.service: Failed with result 'exit-code'. Apr 11 12:23:07 exothermic systemd[1]: factorio1.service: Service hold-off time over, scheduling restart. Apr 11 12:23:07 exothermic systemd[1]: factorio1.service: Scheduled restart job, restart counter is at 5. Apr 11 12:23:07 exothermic systemd[1]: Stopped Factorio1 Server service. Apr 11 12:23:07 exothermic systemd[1]: factorio1.service: Start request repeated too quickly. Apr 11 12:23:07 exothermic systemd[1]: factorio1.service: Failed with result 'exit-code'. Apr 11 12:23:07 exothermic systemd[1]: Failed to start Factorio1 Server service. error.log

maxsupermanhd commented 4 years ago

Please also post factorio.log (If exist)

maxsupermanhd commented 4 years ago

Also check your user/permissions thing, FactoCord must have all rights to run server and read/write to whole factorio+FactoCord directory

szentigrad3 commented 4 years ago

there is no factorio.log, all permission are fine as i can run it standalone but not as a service

maxsupermanhd commented 4 years ago

Try this unit file: https://gist.github.com/maxsupermanhd/0d98ae998913b9611a753b26922973ec

szentigrad3 commented 4 years ago

Try this unit file: https://gist.github.com/maxsupermanhd/0d98ae998913b9611a753b26922973ec

thats works tyvm

szentigrad3 commented 4 years ago

server1 is fine when i try with server 2 i keep getting this

factorio.log

noidea@exothermic:~/FactoCord-2$ systemctl status factorio2.service ● factorio2.service - Factorio server 2 Loaded: loaded (/etc/systemd/system/factorio2.service; enabled; vendor preset: enabled) Active: deactivating (stop) since Sat 2020-04-11 12:23:07 UTC; 1h 9min ago Process: 5011 ExecStop=/usr/bin/tmux kill-session -t factorio2 (code=exited, status=1/FAILURE) Process: 5066 ExecStop=/usr/bin/tmux send-keys -t factorio2 C-c Enter (code=exited, status=0/SUCCESS) Process: 5065 ExecStop=/bin/sleep 10 (code=exited, status=0/SUCCESS) Process: 5064 ExecStop=/usr/bin/tmux send-keys -t factorio2 /quit Enter (code=exited, status=0/SUCCESS) Process: 5063 ExecStop=/bin/sleep 10 (code=exited, status=0/SUCCESS) Process: 5062 ExecStop=/usr/bin/tmux send-keys -t factorio2 /save Exothermic.zip Enter (code=exited, status=0/SUCCESS) Process: 5041 ExecStop=/bin/sleep 10 (code=exited, status=0/SUCCESS) Process: 5028 ExecStop=/usr/bin/tmux send-keys -t factorio2 Server shutdown in 10 seconds! Please save map! Enter (code=exited, status=0/SUCCESS) Process: 5020 ExecStart=/usr/bin/tmux new-session -s factorio2 -d /home/noidea/FactoCord-2/FactoCord-2 (code=exited, status=0/SUCCESS) Main PID: 1526 (code=exited, status=1/FAILURE); Control PID: 5067 (sleep) Tasks: 1 (limit: 4915) CGroup: /system.slice/factorio2.service └─5067 /bin/sleep 10

Apr 11 13:31:47 exothermic systemd[1]: Starting Factorio server 2...

maxsupermanhd commented 4 years ago

I can not see any issue right now. Sorry if I'm blind, feel free to point things up. Can this be closed for now? Anyway, full systemd services support is not yet done so it is up to you setting your server environment, this is personal choice of everyone. My service file is just an a regular example of what can be constructed with terminal multiplexer. Please respond ASAP, working on this right now...

szentigrad3 commented 4 years ago

for some reason i can't run 2 tmux under 1 user account for some reason will only allow me to run 1 server

maxsupermanhd commented 4 years ago

Why not use different users? Also check that you're selecting/creating terminal you actually need to select/create. My service don't do that for you, I'm using special user for each instance, you need to check out tmux docs and make changes into the script if you want to run ti wit another unit concept. This is now not related to FactoCord3, it's your personal fault that you can not create a proper exec structure in unit file.

maxsupermanhd commented 4 years ago

@szentigrad3 Solved? Can this be closed for now?