@@ -2,6 +2,88 @@ package App::Yath::Renderer::Server;
2
2
use strict;
3
3
use warnings;
4
4
5
+ our $VERSION = ' 2.000000' ;
6
+
7
+ use App::Yath::Schema::Util qw/ schema_config_from_settings/ ;
8
+ use App::Yath::Server;
9
+
10
+ use parent ' App::Yath::Renderer::DB' ;
11
+ use Test2::Harness::Util::HashBase qw{
12
+ <config
13
+ <server
14
+ } ;
15
+
16
+ warn " Problem 1: This prevents the test run from completing, all tests finish and it just sits there\n " ;
17
+ warn " Problem 2: Control+c behaves badly\n " ;
18
+ warn " We also need to make sure it waits at the end, but we cannot actually get that far...\n " ;
19
+
20
+ use Getopt::Yath;
21
+ include_options(
22
+ ' App::Yath::Options::Yath' ,
23
+ ' App::Yath::Options::DB' ,
24
+ ' App::Yath::Options::Publish' ,
25
+ ' App::Yath::Options::WebServer' ,
26
+ ' App::Yath::Options::Server' => [qw/ ephemeral/ ],
27
+ );
28
+
29
+ sub start {
30
+ my $self = shift ;
31
+
32
+ my $settings = $self -> settings;
33
+ my $ephemeral = $settings -> server-> ephemeral;
34
+ unless ($ephemeral ) {
35
+ $ephemeral = ' Auto' ;
36
+ $settings -> server-> ephemeral($ephemeral );
37
+ }
38
+
39
+ my $config = $self -> {+CONFIG} //= schema_config_from_settings($settings , ephemeral => $ephemeral );
40
+
41
+ my $qdb_params = {
42
+ single_user => 1,
43
+ single_run => 1,
44
+ no_upload => 1,
45
+ email => undef ,
46
+ };
47
+
48
+ my $server = $self -> {+SERVER} //= App::Yath::Server-> new(schema_config => $config , $settings -> webserver-> all, qdb_params => $qdb_params );
49
+ $server -> start_server(no_importers => 1);
50
+
51
+ sleep 1;
52
+
53
+ $ENV {YATH_URL } = " http://" . $settings -> webserver-> host . " :" . $settings -> webserver-> port . " /" ;
54
+ print " \n Yath URL: $ENV {YATH_URL}\n\n " ;
55
+
56
+ $settings -> db-> config($ENV {YATH_DB_CONFIG }) if $ENV {YATH_DB_CONFIG };
57
+ $settings -> db-> driver($ENV {YATH_DB_DRIVER }) if $ENV {YATH_DB_DRIVER };
58
+ $settings -> db-> name($ENV {YATH_DB_NAME }) if $ENV {YATH_DB_NAME };
59
+ $settings -> db-> user($ENV {YATH_DB_USER }) if $ENV {YATH_DB_USER };
60
+ $settings -> db-> pass($ENV {YATH_DB_PASS }) if $ENV {YATH_DB_PASS };
61
+ $settings -> db-> dsn($ENV {YATH_DB_DSN }) if $ENV {YATH_DB_DSN };
62
+ $settings -> db-> host($ENV {YATH_DB_HOST }) if $ENV {YATH_DB_HOST };
63
+ $settings -> db-> port($ENV {YATH_DB_PORT }) if $ENV {YATH_DB_PORT };
64
+ $settings -> db-> socket ($ENV {YATH_DB_SOCKET }) if $ENV {YATH_DB_SOCKET };
65
+
66
+ $self -> SUPER::start();
67
+ }
68
+
69
+ sub exit_hook {
70
+ my $self = shift ;
71
+
72
+ $self -> SUPER::exit_hook(@_ );
73
+
74
+ print " \n Yath URL: $ENV {YATH_URL}\n\n " ;
75
+ print " Press ENTER/RETURN to stop server and exit\n " ;
76
+ my $x = <STDIN >;
77
+
78
+ delete $self -> {+SERVER};
79
+ delete $self -> {+CONFIG};
80
+
81
+ return ;
82
+ }
83
+
84
+ 1;
85
+
86
+ __END__
5
87
use Carp qw/croak/;
6
88
7
89
use App::Yath::Server;
0 commit comments