+ if ( my $err = $@ ) {
+ handle_startup_error($err);
+ }
+}
+
+sub handle_startup_error {
+ my $err = shift;
+ if ( $err =~ /bind: Permission denied/ ) {
+ handle_bind_error();
+ } else {
+ die
+ "Something went wrong while trying to run RT's standalone web server:\n\t"
+ . $err;
+ }
+}
+
+
+sub handle_bind_error {
+
+ print STDERR <<EOF;
+WARNING: RT couldn't start up a web server on port @{[$port]}.
+This is often the case if you're running @{[$0]} as
+someone other than your system's "root" user.
+EOF
+
+ if ($explicit_port) {
+ print STDERR
+ "Please check your system configuration or choose another port\n\n";
+ } else {
+ print STDERR "\nFor now, RT has chosen an alternate port to run on.\n\n";
+ if ( !$integrity ) {
+ print STDERR <<EOF;
+You can use this server to configure and explore RT. While configuring
+RT, you'll have a chance to set a permanent port and URL for your
+server.
+
+EOF
+ }
+ run_server( 8000 + int( rand(1024) ) );
+ }
+}