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

Sage server launching script #7893

Closed
kwankyu opened this issue Jan 11, 2010 · 16 comments
Closed

Sage server launching script #7893

kwankyu opened this issue Jan 11, 2010 · 16 comments

Comments

@kwankyu
Copy link
Collaborator

kwankyu commented Jan 11, 2010

Many users seem to write individually scripts starting and stopping a Sage server. It would be good that there is a place where these efforts can be combined.

Component: packages: experimental

Keywords: service daemon mode background

Author: Kwankyu Lee

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/7893

@kwankyu

This comment has been minimized.

@kwankyu kwankyu self-assigned this Jan 11, 2010
@kwankyu
Copy link
Collaborator Author

kwankyu commented Jan 11, 2010

comment:2

Anybody is welcome to upload an improved version of the script!

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 15, 2010

comment:3

I revised the script according Donald Alan Morrison's comments: 

  1. The stop_server function does not do error checking to ensure that
    the pid contained in the pid file actually corresponds to a server
    process: https://github.com/sagemath/sage/files/ticket7893/sage-server.gz

30      def stop_server():
31          try:
32              # if sage notebook server is running, "twist.pid" is
created
33              file = open(os.environ!['HOME'] + '/.sage/
sage_notebook.sagenb/twistd.pid', 'r')
34              pid = file.readline()
35              file.close()
36              print "Stopping sage server..."
37              os.system('kill -INT ' + pid)
38          except IOError:
39              print "No sage server running."

Given the frequency of reboots for most users, and the cost to the
user of killing a random process, it would be good to error check
against the actual running process name.

  1. It would be good to add some code that waits for SIG_TERM to
    complete, then optionally sends SIG_KILL.  One can't assume SIG_TERM
    will be handled correctly by the server, especially if it's in a bad
    state.

  2. The script should verify the completion of !Notebook locking #2, then delete the pid
    files.

-Don

@jdemeyer
Copy link

comment:4

Using "screen" is not very portable, so I would avoid that.

@jdemeyer
Copy link

comment:5

Typo: twist.pid -> twistd.pid

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 15, 2010

comment:6

Further revised according to the comment :

Line 50 "blocks" (waits syncronously without checking status); also
half of a second may not be long enough if all memory was used up and
there was excessive paging in/out from the swap file.  One alternative
method is to check for the existence of the pid file periodically for
a longer period (possibly parameterized), and if it is deleted,
recheck that the twistd process has indeed exited else send SIGKILL.

Otherwise, good refactor. :-)

-Don

@cschwan
Copy link
Mannequin

cschwan mannequin commented Oct 16, 2010

comment:7

Look at #381 for a similar effort. On Gentoo I automatically start the Notebook with a runscript - I find it very useful because the only thing I have to do is to open a browser and type in the Notebook's address. It is also possible to access the server from a different PC. To make it a more secure it is run as a different user.

I just added a patch which lets one specify the location of twistd's PID file: #10131 - this might be of interest.

@cschwan
Copy link
Mannequin

cschwan mannequin commented Oct 16, 2010

Attachment: sage-notebook-server.gz

Runscript starting the Notebook server on Gentoo

@cschwan
Copy link
Mannequin

cschwan mannequin commented Oct 16, 2010

comment:8

It should be easy to port the runscript e.g. to debian - as far as I know Debian also has runscript/start-stop-daemon.

@nexttime
Copy link
Mannequin

nexttime mannequin commented Dec 2, 2012

comment:9

Ping. Shouldn't something like this get shipped with Sage?

Also, the Sage Installation Guide lacks this topic. (There's a reference from the online FAQ to #381 though.)

@nexttime
Copy link
Mannequin

nexttime mannequin commented Dec 2, 2012

Changed keywords from none to service daemon mode background

@kwankyu
Copy link
Collaborator Author

kwankyu commented Dec 3, 2012

revised for Sage 5.4; removed "upgrade" command

@kwankyu
Copy link
Collaborator Author

kwankyu commented Dec 3, 2012

Attachment: sage-server.gz

Attachment: sage-server.zip

revised for Sage 5.4; removed "upgrade" command

@kwankyu
Copy link
Collaborator Author

kwankyu commented Mar 23, 2016

comment:11

Nowadays the goal of the script can be achieved easily on the OS level using tools such as Upstart in Ubuntu. Even I, the writer of the scipt, ceased using it long time ago.

@fchapoton
Copy link
Contributor

comment:12

ok, then let us close that.

@fchapoton
Copy link
Contributor

Reviewer: Frédéric Chapoton

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

No branches or pull requests

4 participants