Ahtenus / minecraft-init

Init script for minecraft and bukkit servers
404 stars 125 forks source link

Rogue pidfile found #104

Open fatalerror0x00 opened 11 years ago

fatalerror0x00 commented 11 years ago

When I stop the server it tells me there was a rogue pidfile found which is possibly correct but that means something isn't right I believe since I find it would be weird it would tell me there is a rogue pidfile found at shutdown. Is this maybe because of the waay it checks if the server is off and it seems it's off and hasn't deleted the pidfile? I don't have the source to took look at and the time but this is an issue that should be fixed if possible thanks :)

alfonsojon commented 11 years ago

This affects me as well, except I can't even start my server unfortunately. I'll just use the version prior to the faulty one for now :)

ddugovic commented 11 years ago

I made a fix/workaround to look for ".minecraft" instead of "minecraft": mc_start() { pidfile=${MCPATH}/${SCREEN}.pid

    as_user "cd $MCPATH && screen -dmS $SCREEN $INVOCATION"
    as_user "screen -list | grep '\.$SCREEN' | cut -f1 -d'.' | tr -d -c 0-9 > $pidfile"
fatalerror0x00 commented 11 years ago

sweet I will have to try that and see if that fixes it. It's not preventing me from using my server but it's just annoying to be alerted when it tries to tell me there is a rogue pid file. it just bothers me and makes me think "oh god something is wrong." lol

fatalerror0x00 commented 11 years ago

I see no different in using your work around as I get the very exact same results. But I'm sure maybe I misunderstand something and so I'm doing it wrong maybe :P but as far as I know I am writing this script or well rewritting it and gonna make it more based for my system as I feel this script can be made more effective for my system :) and more features in some areas and less in others

jbondhus commented 11 years ago

I fixed it. The temporary source code is available on my fork of this repository until Ahtenus pulls the changes to his master repo.

ddugovic commented 11 years ago

Cool. I must have only changed it in a way that worked for my system. At any rate it was fun learning how the script works. I'll try out jbondhus' fix which is probably more generic and usable.

Keep up the great work!

jbondhus commented 11 years ago

We all learn from our mistakes, I taught myself bash at age 17 off this script. I'm in college so I can't dedicate much time to it, but I enjoy spending a couple hours between classes working on it. It's kind of like a hobby project for me (well, and I put it on my resume for applying at my university's IT department), so it has it's advantages. :)

fatalerror0x00 commented 11 years ago

yeah i been kinda teaching myself bash with this script too as it has alot of basics stuff to it but at the same time alot of intermediate stuff too. I know enough to create my own version of this script very few commands I don't know anything about still and may never understand them but i can always depend on it to work at least :) I'll look at jbondhus source see what i can do i'm not at the house witht he computer and I don't know how to download the file to my computer at home over ssh (I don't understand commandline downloading -.-)

jbondhus commented 11 years ago

As of current it will still tell you rogue pid file when quitting, but it isn't a problem, merely a minor bug that is only cosmetic. Everything else is functional. If, however, it still doesn't work for you, please email me so I can fix it. (My email is in my profile)

jbondhus commented 11 years ago

@fatalerror0x00 Ssh downloading is easy. Just ssh into the computer you want to download the file at, navigate to the directory, and run the command "wget www.example.com/fileyouwanttodownload". Without the quotation marks of course. Then you are free to rename it, edit it, etc. For example, to download my script, you would go "wget https://raw.github.com/jbondhus/minecraft-init/master/minecraft". :)

Rovanion commented 11 years ago

Why not use git now that you're, well, on a git version tracker? ssh to the server and then git pull git://github.com/jbondhus/minecraft-init.git from your existing git repo or git clone git:// github.com/jbondhus/minecraft-init.git to create a new local repo.

2012/11/13 Jonathan Bondhus notifications@github.com

@fatalerror0x00 https://github.com/fatalerror0x00 Ssh downloading is easy. Just ssh into the computer you want to download the file at, navigate to the directory, and go "wget www.example.com/fileyouwanttodownload". Without the quotation marks of course. Then you are free to rename it, edit it, etc. For example, to download my script, you would go "wget https://raw.github.com/jbondhus/minecraft-init/master/minecraft". :)

— Reply to this email directly or view it on GitHubhttps://github.com/Ahtenus/minecraft-init/issues/104#issuecomment-10311303.

fatalerror0x00 commented 11 years ago

Thanks I'll have to try those out I tried wget and that didn't seem to work but I may have not done the right directories and git I just couldn't figure out what to type at all before the git address as this site gives you the address but I will have to figure this out now that i have some sort of lead. Anyone got any ideas on how to fix this rogue pidfile upon shutdown but stil check for it as normal at startup? nice to have someone post a fix for that if possible I haven't looked far enough in the code still. Working on creating my own version of the script butt currently am actually stuck on loading config file since if symlink is used to launch the script but the config file is named wrong it ignores else all together because of the way if statements work, which in turn makes using different methods to find your config file difficult which is something I'm trying to fix and put into my script. :)

ddugovic commented 11 years ago

I'm guessing the "rogue pidfile found" on shutdown happens because the server shuts down prior to deletion of the pidfile. If that is the problem, that doesn't bother me.

jbondhus commented 11 years ago

It seems to be erasing the PID file every time it shuts down by going echo > $pidfile. What I need to do is find where it is doing this and tell it to erase the PID file instead. Another possibility is that it's checking for the PID file before the PID file is removed, which is probable, I'll take a look into both of these options. I have a project deadline today though, so I'll have to take a look at it on the weekend when I get time. Keep in mind that I have a full 16 credit course load on top of a social life and free time (no, this isn't my only free time), and my schedule is extremely volatile/tentative, so I can't dedicate all my time to it.

tulpn commented 11 years ago

I changed line 55: pid=$(cat $pidfile) to pid=$(head -1 $pidfile)

And it worked perfectly. OpenSuse

fatalerror0x00 commented 11 years ago

Now what does head -1 do instead of cat? cause from what i can see it displays just the first line of code or in your case gives the variable the first line but it already only has one line. So i don't see how that changes any result :P

ddugovic commented 11 years ago

The bug was (at least on my computer) that the pidfile contained more than just the pid, because the "grep" used to create the pid found more than one match. Although "head -1" would have fixed reading of the file, I'd prefer to find a way to write only the pid to the pidfile.

jbondhus commented 11 years ago

@bschwabe Didn't fix it on my computer. :( I'm not having an issue with the wrong text, it's because of it checking for the file after the server's shutting down and not expecting it (I think). I talked about this more above. I will still push this change suggested by @bschwabe if it will fix it for other people however.

fatalerror0x00 commented 11 years ago

I think I know now what is wrong but i won't get to test it till later.

fatalerror0x00 commented 11 years ago

I think I found the issue that will fix this issue for some people i haven't tested it but I'm almost positive. rogue pid file for some users (I believe it depends on distros) if you find pid=$(ps ax | grep -v grep | grep "${SCREEN} ${INVOCATION}" | cut -f1 -d' ') and change cut -f1 -d' ' to cut -f6 -d' ' it will work at least for me it should yet I have not tested this but i just sshed in and did that as ps command with cutting and I get my username the way that the script wants to do it but if I do f6 it graps the PID instead

fatalerror0x00 commented 11 years ago

Can't garentee that will fix the issue but i think it's a good start to make sure it's grabbing the PID and not some ofther information

fatalerror0x00 commented 11 years ago

actually f6 is a mistake or not a mistake but works if you use the way I do to get your process list I'm sorry about that guys

I use ps -ef sorry

jbondhus commented 11 years ago

Wait - so do you want me to take back that commit? I already got it pulled into the main project, Ahtenus was unusually fast in responding and it got pulled within an hour.

marceloschmidt commented 11 years ago

Guys, I'm getting the "Rogue pidfile found" problem (I can't start the server). I've tried to solve it myself, but I couldn't... I tried using ps -ef instead of ps ax and I've also tried changing the order of statements on if then else on lines 56-62. To me it looks like that if the if statement with "ps ax | grep .... " returns something, it means the server is running, and should then return 1 instead of 0. Anyway, it didn't work... any ideas on what I could try next? I'm running Ubuntu, BTW.

ddugovic commented 11 years ago

Since the server isn't currently running, try two things:

  1. Examine the pidfile if it exists (minecraft/minecraft.pid) and see if it's been corrupted (if it contains more than just a pid)
  2. Delete the pidfile and try to start the server
fatalerror0x00 commented 11 years ago

No don't take back the commit it's fine :P just a mistake on my part not paying attention to difference in code :P if it's px -ef your refering to and using f6 either way though it's fine I think ps -ef shoudl be used instead because I think it's more linux based if you read the man page for ps it's supposed to show ALL processes for linux systems which is basically what almost all users are using. Still haven't figured out if slackware is linux or bsd but i use the linux way of doing thing because usually thats how slackware does stuff it seems :P sorry it's been a while since I've looked at this guys I been busy with other code projects and screwing up my linux OS to the point I need to reinstall everything -.-

chrisgoodall commented 11 years ago

I had this problem and the issue was that my host name was the same as my screen name. So when the script listed all the screens, there were two that matched (in my case, both had 'minecraft' as the name). The result is that both process ids get put into the .pid file. Renaming my screen fixed the problem.

megakode commented 9 years ago

doing a "screen -wipe" in the shell also helps, if you have old dead screen sessions hanging. This was the problem in my case.