Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It was the cronserver mgmt command all along #3152

Merged
merged 5 commits into from
Mar 10, 2015

Conversation

MCGallaspy
Copy link
Contributor

cronserver gunks up the works for the other kaserve command.
Not clear to me why. I'm calling not executing it a workaround.
Does it actually do anything?
Also, fixed a bug in the 'status' command. Windows doesn't like
an HTTPConnection with "0.0.0.0" address.

This provisionally addressed #2919, but I think we need to look more closely at why the cronserver management command is causing these issues on Windows. kalite.bat start/stop/status all work in this state, though. Sad me is getting slightly less sad. :|

cronserver gunks up the works for the other kaserve command.
Not clear to me why. I'm calling not executing it a workaround.
Does it actually do anything?
Also, fixed a bug in the 'status' command. Windows doesn't like
an HTTPConnection with "0.0.0.0" address.
@jamalex jamalex self-assigned this Feb 28, 2015
@jamalex
Copy link
Member

jamalex commented Feb 28, 2015

Excellent debugging!

We can't just skip starting up the cronserver, though -- it's used to auto-sync data in the background every hour, which is important. Do you think it's an issue with spawning the thread? Where exactly does it freeze up?

Possible alternative solution, if we can't get the thread spawning working, is to modify the Windows GUI to:

  • pass --skip-job-scheduler when running kaserve
  • separately run the cronserver command

@MCGallaspy
Copy link
Contributor Author

Where exactly does it freeze up?

It doesn't freeze up, so much as a second thread with the exact same command is run (so for example, if I execute python.exe kalite start then another thread also trying to run that command is started) which upon finding the startup lock file exists, dies and kills the original thread. Again, it's not yet clear to me why this is happening, I'll have to take a closer look at the cronserver command.

@MCGallaspy
Copy link
Contributor Author

I'm not really any closer to understanding this issue. I'm not throwing in the towel, but I'm making an open call for help/insight.

For some reason, the thread running the cronserver management command
(in Windows only) barfs and kills the whole process. This prevents the
server from starting. Why does it get sick and die? Who knows?
A better solution on windows (better than trying to UNIX-ly daemonize programs)
seems to be to create windows services. Then kalitectl.py can simply start
and stop those services. Just to be clear, there's no issue on windows with
running the cronserver and kaserve command in separate processes (say, in different
instances of cmd.exe or using subprocess.Popen), there's only an issue when they
are run in different threads belonging to the same process.
@MCGallaspy
Copy link
Contributor Author

My commit message, for posterity:
For some reason, the thread running the cronserver management command
(in Windows only) barfs and kills the whole process. This prevents the
server from starting. Why does it get sick and die? Who knows?
A better solution on windows (better than trying to UNIX-ly daemonize programs)
seems to be to create windows services. Then kalitectl.py can simply start
and stop those services. Just to be clear, there's no issue on windows with
running the cronserver and kaserve command in separate processes (say, in different
instances of cmd.exe or using subprocess.Popen), there's only an issue when they
are run in different threads belonging to the same process.

@aronasorman aronasorman added this to the 0.13.x milestone Mar 9, 2015
thread = ManageThread(command, args=args, name=" ".join([command]+args))
thread.start()
else:
Popen([sys.executable, os.path.abspath(sys.argv[0]), "manage", command] + args, creationflags=CREATE_NEW_PROCESS_GROUP)

This comment was marked as spam.

This comment was marked as spam.

@MCGallaspy
Copy link
Contributor Author

@EdDixon I think we can merge this if you tell us that the bin/windows/kalite.bat start/stop commands work as expected in Windows 7.

@aronasorman
Copy link
Collaborator

Merging this. @EdDixon please test this tomorrow in the bug bash.

aronasorman added a commit that referenced this pull request Mar 10, 2015
It was the cronserver mgmt command all along
@aronasorman aronasorman merged commit 31b231a into learningequality:develop Mar 10, 2015
@aronasorman aronasorman deleted the windows-cli-fixes branch March 10, 2015 00:35
@@ -219,7 +222,7 @@ def get_pid():
listen_port = getattr(settings, "CHERRYPY_PORT", LISTEN_PORT)

# Timeout is 1 second, we don't want the status command to be slow
conn = httplib.HTTPConnection(LISTEN_ADDRESS, listen_port, timeout=3)
conn = httplib.HTTPConnection("127.0.0.1", listen_port, timeout=3)

This comment was marked as spam.

This comment was marked as spam.

@benjaoming
Copy link
Contributor

Nice getting this fixed!! I think it's problematic that kalite is using "0.0.0.0" and not a deliberate IP-address. It isn't normal precisely because of the reason we've just seen.

It would be more "normal" (as per my personal experience with linux apps) to default to "127.0.0.1", furthermore to allow binding to multiple addresses, including "0.0.0.0" which could be deliberately set on a system that supports it.

Further... it reminds of the need to get Celery #2891

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants