Forward porting spectre stop fix. Moved from IKC to interrupt based.
This commit is contained in:
parent
10755c3b83
commit
f8b8f9da37
5 changed files with 59 additions and 28 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
7.7.17
|
7.7.17
|
||||||
- fixed #10654: Story Archive: Search not working properly
|
- fixed #10654: Story Archive: Search not working properly
|
||||||
|
- fixed #10692: Unprivileged users can stop spectre
|
||||||
- fixed search indexer concatenates keywords to content.
|
- fixed search indexer concatenates keywords to content.
|
||||||
- fixed Index Story fields for Search (headline, subtitle, location, byline, highlights, story)
|
- fixed Index Story fields for Search (headline, subtitle, location, byline, highlights, story)
|
||||||
- fixed #10619: Pagination macro
|
- fixed #10619: Pagination macro
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@ save you many hours of grief.
|
||||||
|
|
||||||
7.7.17
|
7.7.17
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
|
* Spectre now works like many other programs and writes a PID
|
||||||
|
file. The location of that file is required to be in your
|
||||||
|
spectre.conf file to start or stop. After installing this
|
||||||
|
version, you will need to manually kill spectre and then
|
||||||
|
restart it.
|
||||||
|
|
||||||
* The Default Gallery Album View Thumbnails template has been reworked
|
* The Default Gallery Album View Thumbnails template has been reworked
|
||||||
to get rid of intermittent rendering bugs with IE7. The thumbnail
|
to get rid of intermittent rendering bugs with IE7. The thumbnail
|
||||||
pop-up is now completely CSS. The thumbnails.js file is still available,
|
pop-up is now completely CSS. The thumbnails.js file is still available,
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,11 @@
|
||||||
# It should be safe to set this to 1 any time spectre and WebGUI
|
# It should be safe to set this to 1 any time spectre and WebGUI
|
||||||
# are running on the same server.
|
# are running on the same server.
|
||||||
|
|
||||||
"ignoreEnvProxy" : 0
|
"ignoreEnvProxy" : 0,
|
||||||
|
|
||||||
|
# The location of the file that keeps track of the master spectre processId.
|
||||||
|
|
||||||
|
"pidFile" : "/var/run/spectre.pid"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,21 @@ use Spectre::Cron;
|
||||||
use Spectre::Workflow;
|
use Spectre::Workflow;
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 _safe_shutdown ( )
|
||||||
|
|
||||||
|
Stops the kernel when TERM signal is received
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub _safe_shutdown {
|
||||||
|
my ($obj) = @_[ OBJECT ];
|
||||||
|
$obj->error('Spectre shut down');
|
||||||
|
POE::Kernel->stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 _start ( )
|
=head2 _start ( )
|
||||||
|
|
@ -41,22 +56,9 @@ sub _start {
|
||||||
$kernel->alias_set($serviceName);
|
$kernel->alias_set($serviceName);
|
||||||
$kernel->call( IKC => publish => $serviceName, $publicEvents );
|
$kernel->call( IKC => publish => $serviceName, $publicEvents );
|
||||||
$kernel->delay_set("loadSiteData",3);
|
$kernel->delay_set("loadSiteData",3);
|
||||||
|
$kernel->sig( TERM => '_safe_shutdown' );
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 _stop ( )
|
|
||||||
|
|
||||||
Gracefully shuts down the admin interface.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub _stop {
|
|
||||||
my ($kernel, $self) = @_[KERNEL, OBJECT];
|
|
||||||
$self->debug("Stopping Spectre administrative manager.");
|
|
||||||
undef $self;
|
|
||||||
$kernel->stop;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -204,8 +206,8 @@ sub new {
|
||||||
name => 'Spectre'
|
name => 'Spectre'
|
||||||
);
|
);
|
||||||
POE::Session->create(
|
POE::Session->create(
|
||||||
object_states => [ $self => {_start=>"_start", _stop=>"_stop", "shutdown"=>"_stop", "ping"=>"ping", "loadSiteData"=>"loadSiteData"} ],
|
object_states => [ $self => {_start=>"_start", "ping"=>"ping", "loadSiteData"=>"loadSiteData", "_safe_shutdown" => "_safe_shutdown"} ],
|
||||||
args=>[["shutdown","ping"]]
|
args=>[["ping"]]
|
||||||
);
|
);
|
||||||
Spectre::Workflow->new($config, $logger, $debug);
|
Spectre::Workflow->new($config, $logger, $debug);
|
||||||
Spectre::Cron->new($config, $logger, $debug);
|
Spectre::Cron->new($config, $logger, $debug);
|
||||||
|
|
|
||||||
|
|
@ -68,17 +68,22 @@ STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($shutdown) {
|
if ($shutdown) {
|
||||||
my $remote = create_ikc_client(
|
local $/;
|
||||||
port=>$config->get("port"),
|
my $pidFileName = $config->get('pidFile');
|
||||||
ip=>$config->get("ip"),
|
if (! $pidFileName) {
|
||||||
name=>rand(100000),
|
die "No pidFile specified in spectre.conf\n";
|
||||||
timeout=>10
|
}
|
||||||
);
|
open my $pidFile, '<', $pidFileName or
|
||||||
die $POE::Component::IKC::ClientLite::error unless $remote;
|
die "Unable to open pidFile ($pidFileName) for writing: $!\n";
|
||||||
my $result = $remote->post('admin/shutdown');
|
my $spectrePid = <$pidFile>;
|
||||||
die $POE::Component::IKC::ClientLite::error unless defined $result;
|
close $pidFile or
|
||||||
$remote->disconnect;
|
die "Unable to close pidFile ($pidFileName) after writing: $!\n";
|
||||||
undef $remote;
|
chomp $spectrePid;
|
||||||
|
kill 15, $spectrePid;
|
||||||
|
sleep 1;
|
||||||
|
kill 9, $spectrePid;
|
||||||
|
unlink $pidFileName or
|
||||||
|
die "Unable to remove PID file\n";
|
||||||
}
|
}
|
||||||
elsif ($ping) {
|
elsif ($ping) {
|
||||||
my $res = ping();
|
my $res = ping();
|
||||||
|
|
@ -95,18 +100,31 @@ elsif ($run) {
|
||||||
Spectre::Admin->new($config, $debug);
|
Spectre::Admin->new($config, $debug);
|
||||||
}
|
}
|
||||||
elsif ($daemon) {
|
elsif ($daemon) {
|
||||||
|
my $pidFileName = $config->get('pidFile');
|
||||||
if (!ping()) {
|
if (!ping()) {
|
||||||
die "Spectre is already running.\n";
|
die "Spectre is already running.\n";
|
||||||
}
|
}
|
||||||
|
elsif (-e $pidFileName){
|
||||||
|
die "pidFile $pidFileName already exists\n";
|
||||||
|
}
|
||||||
#fork and exit(sleep(1) and print((ping())?"Spectre failed to start!\n":"Spectre started successfully!\n")); #Can't have right now.
|
#fork and exit(sleep(1) and print((ping())?"Spectre failed to start!\n":"Spectre started successfully!\n")); #Can't have right now.
|
||||||
require POSIX;
|
require POSIX;
|
||||||
fork and exit;
|
fork and exit;
|
||||||
POSIX::setsid();
|
POSIX::setsid();
|
||||||
|
##Write the PID file
|
||||||
|
if (! $pidFileName) {
|
||||||
|
die "No pidFile specified in spectre.conf\n";
|
||||||
|
}
|
||||||
|
open my $pidFile, '>', $pidFileName or
|
||||||
|
die "Unable to open pidFile ($pidFileName) for writing: $!\n";
|
||||||
chdir "/";
|
chdir "/";
|
||||||
open STDIN, "+>", File::Spec->devnull;
|
open STDIN, "+>", File::Spec->devnull;
|
||||||
open STDOUT, "+>&STDIN";
|
open STDOUT, "+>&STDIN";
|
||||||
open STDERR, "+>&STDIN";
|
open STDERR, "+>&STDIN";
|
||||||
fork and exit;
|
fork and exit;
|
||||||
|
print $pidFile $$."\n";
|
||||||
|
close $pidFile or
|
||||||
|
die "Unable to close pidFile ($pidFileName) after writing: $!\n";
|
||||||
Spectre::Admin->new($config, $debug);
|
Spectre::Admin->new($config, $debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue