WebFaction
Community site: login faq

I have updated my cherrypy application. How do I restart it now so that the code changes are applied to the live site?

Thanks, Patrick

asked 14 Nov '12, 12:12

pchasco
112
accept rate: 0%


I figured it out.

cat pid kill -9 [whatever the pid is]

permanent link

answered 14 Nov '12, 13:55

pchasco
112
accept rate: 0%

Instructions for starting and stopping your applications may be found in the "Description" section of your app info in the control panel. For example:

To start the server, run: ~/webapps/<app name>/autostart.cgi
To stop the server, run: kill $(cat $HOME/webapps/<app name>/pid)
permanent link

answered 14 Nov '12, 14:02

seanf
12.2k42136
accept rate: 37%

Along these lines, what's a good way to automatically restart a CP app with cron? I've tried running the autostart.cgi script with cron, but the process seems to get killed eventually?

Thanks

(15 Nov '12, 01:23) escher

The right way to do this is to run a simple script with cron which can check to see if your application is running, and only start it if it's not running. This is described here:

http://community.webfaction.com/questions/6157/watchdog-script-to-keep-process-running-with-cron

That said, if your processes are repeatedly getting killed, you might want to check your memory usage to see if your processes are exceeding your RAM quota.

(15 Nov '12, 01:35) ryans

No, it's not that WF is killing my processes; it's just that after 24 hours or so they start eating up like 150MB ram, so there must be some memory leak somewhere.

Also, I think the SH script you linked won't quite work -- it checks if the program is still running. I'd like to just "restart" it, every 12 hours, whether or not it's already running.

(15 Nov '12, 01:44) escher

Oh, if you actually want to just restart the process, that's even easier. Just write a script which does something like:

kill $(cat $HOME/webapps/<app name>/pid)
sleep 10
kill -9 $(cat $HOME/webapps/<app name>/pid) # just in case
sleep 5
$HOME/webapps/<app name>/autostart.cgi

And then run that script every 12 hours.

(15 Nov '12, 01:49) ryans

Well, I've tried something like this already, but the Site app seems to get 'killed' after a certain period -- perhaps because the job is started by Cron, and Cron kills a process after it runs too long?

(15 Nov '12, 02:00) escher

No, we never kill a process because it runs too long, and a "Site app" is a control panel machination; it doesn't know anything about the processes running under your account and can't ever get killed directly.

If your application is not receiving a SIGTERM, it's crashing. If it is receiving a SIGTERM from our system, it should only be as a result of memory usage exceeded. We don't arbitrarily or haphazardly terminate processes.

(15 Nov '12, 02:36) ryans

Hmm, OK. I'll try it again & start a new thread if I notice this behaviour. Thanks Ryan.

(15 Nov '12, 02:52) escher
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×32
×24

question asked: 14 Nov '12, 12:12

question was seen: 6,601 times

last updated: 15 Nov '12, 02:52

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM