Go to Post Design is iterative, right? - JesseK [more]
Home
Go Back   Chief Delphi > Technical > IT / Communications > Website Design/Showcase
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-11-2013, 22:49
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Lightbulb Keeping a Server alive

Hey guys,
My RPi Web server always crashes at the wrong times (when I am not at home). I came up with this solution to reset it automatically:

Here is the sequence:
i2c interface between MCU and Pi
MCU controlling power to Pi via relay
MCU keeps pinging the Pi via i2C (sending a packet and waiting for response)
If the MCU fails the ping 5 times in a row, calls the reboot command (sudo reboot)
MCU waits 2 minutes
MCU pings the Pi a few times to see if it is alive again
Otherwise, MCU resets Pi by unplugging it and plugging it back in (relay)
MCU calls command to clear our corruptions on the HDD
MCU reboots server
Server up again!
  #2   Spotlight this post!  
Unread 20-11-2013, 19:56
Zach O's Avatar
Zach O Zach O is offline
Building an iOS app @ glacial speed
AKA: @FRCZach
no team
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Atlanta, GA
Posts: 512
Zach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond repute
Re: Keeping a Server alive

Hmm. A better idea might be to look at why your web server crashes and fix it. Have you checked your server logs?
__________________
Follow me twitter dot com slash frc zach
  #3   Spotlight this post!  
Unread 20-11-2013, 20:11
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Keeping a Server alive

Well, yep. That is always the best idea. However, when running on a Raspberry Pi, getting DoSsed can easily crash the server!
  #4   Spotlight this post!  
Unread 20-11-2013, 20:15
BBray_T1296's Avatar
BBray_T1296 BBray_T1296 is offline
I am Dave! Yognaut
AKA: Brian Bray
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Rockwall, TX
Posts: 947
BBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond repute
Re: Keeping a Server alive

Quote:
Originally Posted by yash101 View Post
Hey guys,
My RPi Web server always crashes at the wrong times (when I am not at home). I came up with this solution to reset it automatically:

Here is the sequence:
i2c interface between MCU and Pi
MCU controlling power to Pi via relay
MCU keeps pinging the Pi via i2C (sending a packet and waiting for response)
If the MCU fails the ping 5 times in a row, calls the reboot command (sudo reboot)
MCU waits 2 minutes
MCU pings the Pi a few times to see if it is alive again
Otherwise, MCU resets Pi by unplugging it and plugging it back in (relay)
MCU calls command to clear our corruptions on the HDD
MCU reboots server
Server up again!
What happens if your MCU crashes?
__________________
If molecular reactions are deterministic, are all universes identical?

RIP David Shafer: you will be missed


  #5   Spotlight this post!  
Unread 20-11-2013, 20:16
Zach O's Avatar
Zach O Zach O is offline
Building an iOS app @ glacial speed
AKA: @FRCZach
no team
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Atlanta, GA
Posts: 512
Zach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond reputeZach O has a reputation beyond repute
Re: Keeping a Server alive

Maybe. But is that your problem? What are you using to serve your website? (Apache, Nginx, etc) Is it a problem with traffic to the website, or some other unhandled error on the server?
__________________
Follow me twitter dot com slash frc zach
  #6   Spotlight this post!  
Unread 20-11-2013, 20:18
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Lightbulb Re: Keeping a Server alive

The typical DoS is high traffic. I have both Nginx and Apache installed. Apache handles dynamic HTML and Nginx handles the static files, wherever possible.

Running AB through localhost, I have tested my server at 100,000 hits, ten at a time! However, that was my nginx, which I have not released the port number to the public. WordPrss is a tad too heavy on the resources to allow more than 5 active connections at at time.

Also, is it often that MCUs crash? I have never heard of an Arduino crashing, because of how simple the bootloader and kernel is!

Last edited by yash101 : 20-11-2013 at 20:21.
  #7   Spotlight this post!  
Unread 20-11-2013, 20:28
magnets's Avatar
magnets magnets is offline
Registered User
no team
 
Join Date: Jun 2013
Rookie Year: 2012
Location: United States
Posts: 748
magnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond repute
Re: Keeping a Server alive

To echo a previous poster, find out exactly why the server is crashing. Is it too much memory usage? When it crashes, does the pi freeze, or does the service running the web server stop? You could make a simple script that restarts your web server once the memory usage exceeds 95%. Also, you could use cron to hourly restart the server if it has crashed.
  #8   Spotlight this post!  
Unread 20-11-2013, 20:34
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Keeping a Server alive

What I mean by a crash is a kernel panic. The Pi is frozen. I cannot SSH to it. I cannot UART to it and I cannot connect a display, keyboard and mouse!
Before, server crashes were common. Recently, I have configured the server to refuse requests if it recieves too many. That way, DoSers are denied access to a 500 error message. Now, I would like the 500 message be sent to nginx instead, where less RAM will be used.
  #9   Spotlight this post!  
Unread 21-11-2013, 11:43
Scott L.'s Avatar
Scott L. Scott L. is offline
Registered User
FRC #0222 (Tigertrons)
Team Role: Engineer
 
Join Date: Sep 2003
Rookie Year: 1998
Location: Tunkhannock PA
Posts: 290
Scott L. is just really niceScott L. is just really niceScott L. is just really niceScott L. is just really niceScott L. is just really nice
Send a message via AIM to Scott L.
Talking Re: Keeping a Server alive

What model is it? Model A has problems from what i read on trhis site: http://www.raspberrypi.org/phpBB3/vi...33763&p=319358

might be related to the Pi itself, and not just because its set as a webserver.
__________________
You can do anything, if you put your mind to it!!!
http://asp.shinraikon.com
  #10   Spotlight this post!  
Unread 21-11-2013, 12:44
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Keeping a Server alive

I have a Model B, 512 MB. I know it isn't the Pi's fault because it is very stable until I send 100,000 requests in five minutes. The stability is mostly because the Pi runs Raspbian rom a hard disk instead of an SD/eMMC card!
  #11   Spotlight this post!  
Unread 21-11-2013, 12:55
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,562
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
This is fairly common and is called a watchdog. They make dedicated controllers or even circuitry in micro controllers to do this automatically.
  #12   Spotlight this post!  
Unread 21-11-2013, 22:25
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Keeping a Server alive

Yes. I want to make it more-or-less a watchdog. Also, I would like that MCU controlling the cooling system because I currently have a fan that runs 24/7! That's a lot of noise and wasted energy! I would also like to be able to log the boot and command input/output to a text file on an SD card to allow me to debug any crashes or kernel panics, if any text is sent over UART.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 15:51.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi