-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ pm_to_blib | |
config.pl | ||
config.pl.bak | ||
MYMETA.* | ||
start.sh.log | ||
yancha.pid | ||
access_log | ||
.htpasswd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
#!/bin/sh | ||
twiggy -l :3000 chat.psgi | ||
#export YANCHA_DEBUG=1 | ||
#twiggy -l :3000 --access-log access_log chat.psgi & | ||
echo $! > yancha.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
kill `cat yancha.pid` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use utf8; | ||
use warnings; | ||
use Time::Piece; | ||
use LWP::UserAgent; | ||
|
||
my $YANCHA_URL = 'http://localhost:3000/'; | ||
|
||
my $ua = LWP::UserAgent->new; | ||
$ua->timeout(10); | ||
print localtime->datetime; | ||
print " watch start\n"; | ||
|
||
while(1){ | ||
my $response = eval { | ||
local $SIG{ALRM} = sub { die HTTP::Response->new(408, "got alarm, read timeout.") }; | ||
alarm 10; | ||
my $res = $ua->get($YANCHA_URL); | ||
alarm 0; | ||
$res; | ||
}; | ||
|
||
if ($response->is_success) { | ||
# print "OK\n"; | ||
}else{ | ||
print localtime->datetime; | ||
print " NG! \n"; | ||
`kill \`cat yancha.pid\``; | ||
# must restart | ||
`nohup ./start.sh >> start.sh.log 2>&1 &`; | ||
} | ||
sleep 10; | ||
} | ||
|
||
=pod | ||
Yancha Auto Rebooter | ||
Author: uzulla | ||
HOW TO START | ||
0. edit watcher.pl ($YANCHA_URL) | ||
1. run watcher.pl (You can use this an alternate for start.sh.) | ||
HOW TO STOP | ||
1, kill watchr.pl | ||
2, stop.sh | ||
=cut |