????
Current Path : /scripts/ |
Current File : //scripts/restartsrv_tomcat |
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - restartsrv_tomcat Copyright 2018 cPanel, Inc. # All rights Reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited use strict; use warnings; use Cpanel::RestartSrv::Lock (); use Cpanel::RestartSrv (); use Cpanel::Chkservd::Tiny (); use Cpanel::Exception (); use Cpanel::Server::Type (); eval { local $SIG{'__DIE__'}; require Cpanel::Rlimit; Cpanel::Rlimit::set_rlimit_to_infinity(); }; if ( Cpanel::Server::Type::is_dnsonly() ) { print STDERR "tomcat service is disabled for dnsonly\n"; exit(1); } Cpanel::RestartSrv::setuppath(); my $system = lc $^O; my ( $restart, $check, $status ) = Cpanel::RestartSrv::parseargv(); my $iscript = ''; my $initdir = ''; my $processowner = getpwnam('tomcat') ? 'tomcat' : 'root'; my $service = 'tomcat'; my $disabled = 0; my $installed = 1; my $regex = qr{\btomcat\b}; # cannot use the default rule: ^tomcat if ( !-x '/usr/sbin/starttomcat' ) { $installed = 0; } if ( -e '/etc/tomcatdisable' ) { $disabled = 1; } if ( $restart && !$disabled ) { die Cpanel::Exception::create( 'Services::NotInstalled', [ service => $service ] ) if !$installed; my $lock = Cpanel::RestartSrv::Lock->new($service); #--restart or nothing (restart service) Cpanel::Chkservd::Tiny::suspend_service( $service, 120 ); Cpanel::RestartSrv::nooutputsystem('/usr/sbin/stoptomcat'); Cpanel::RestartSrv::doomedprocess($service); if ( $restart != -1 ) { Cpanel::RestartSrv::logged_startup( 'tomcat', 1, ['/usr/sbin/starttomcat'] ); } $lock->release() if $lock; } elsif ($status) { #--status (show ps) if ($disabled) { print "$service is disabled\n"; } else { die Cpanel::Exception::create( 'Services::NotInstalled', [ service => $service ] ) if !$installed; print Cpanel::RestartSrv::check_service( 'service' => $service, 'user' => $processowner, 'regex' => $regex ); } } elsif ($check) { exit if ($disabled); die Cpanel::Exception::create( 'Services::NotInstalled', [ service => $service ] ) if !$installed; if ( Cpanel::RestartSrv::check_service( 'service' => $service, 'user' => $processowner, 'regex' => $regex ) eq '' ) { print "$service is not running\n"; } }