Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    10

    Default cpgs_server_ctl Needs Updating + Other small problems

    So after finally updating our servers to the new 0.7.2 with working restartserver command, I've noticed that the cpgs_server_ctl also needed updating. At the moment it fails to start servers which causes the cpgs_chk and gameserv_restart.sh scripts to fail.

    I've patched this myself, so if anyone else is having issues with this here's a temporary fix (/var/cpanel/cpgs/cpgs_server_ctl):
    Code:
    #!/usr/bin/perl
    #
    # /path/to/this_script action user game install#
    # ex: /var/cpanel/cpgs/cpgs_server_ctl start fragger hl2 2
    
    use IPC::Open2;
    use Storable qw(store retrieve nfreeze thaw dclone);
    
    my $os=lc(`uname -s`);
    $os =~ s/(\r|\n)//g;
    
    my $act = $ARGV[0];
    my $user = $ARGV[1];
    my $game = $ARGV[2];
    my $srvn = $ARGV[3];
    my $restart = $ARGV[4];
    
    if((!$act) || (!$user) || (!$game)) { 
    	msglog("Missing a required argument. action($act) user($user) game($game) srvn($srvn)");
    	exit(0);
    }
    
    if($srvn !~ /^\d+$/) {
    	msglog("Missing a required argument. action($act) user($user) game($game) srvn($srvn)");
    	exit(0);
    }
    
    my @PW = getpwnam($user);
    if(!@PW[0]) { 
    	msglog("Could not find user \"$user\", aborting.");
    	exit(0);
    }
    
    if($act eq 'stop') {
    	&stopsrv;
    } elsif($act eq 'start') {
    	&startsrv;
    } elsif($act eq 'restart') {
    	&stopsrv;
    	sleep(2);
    	&startsrv;
    } else {
    	msglog("Unknown action: $act (stop|start|restart)");
    }
    
    exit(0);
    
    ###############################################################################
    ######[ subroutines ]##########################################################
    ###############################################################################
    
    sub stopsrv {
    	$start_args{'cpgs_user'} = $user;
    	$start_args{'cpgs_game'} = $game;
    	$start_args{'cpgs_srvn'} = $srvn;
    	$start_args{'verbose'}=0;
    	my $ser = nfreeze \%start_args;
    	my @rp = sendssl("127.0.0.1 stopserver " . encode_base64($ser));
    	msglog("@rp");
    }
    
    sub startsrv {
    	my @rp1 = sendssl("127.0.0.1 singleisrunning $user $game $srvn");
    	my $reply;
    	foreach my $ln(@rp1) { $reply .= $ln; }
    	if($reply =~ /^OK:\s+(.*)/) {
    		if("$1" eq "Down") {
    			$start_args{'cpgs_user'} = $user;
    			$start_args{'cpgs_game'} = $game;
    			$start_args{'cpgs_srvn'} = $srvn;
    			$start_args{'verbose'}=0;
    			$start_args{'restart'} = $restart;
    			my $ser = nfreeze \%start_args;
    			my @rp2 = sendssl("127.0.0.1 startserver " . encode_base64($ser));
    			msglog("@rp2");
    		} # else { ignore };
    	} else {
    		msglog("Could not connect to cPGSD on 127.0.0.1 to check running statis for $user $game $srvn");
    	}
    }
    
    sub sendssl {
    	my $arg="@_";
    	my $ret;
    	my @reply;
    	my $pid = open2(\*SSLREAD,\*SSLWRITE,"/var/cpanel/cpgs/cpgs_comm",$arg);
    	close(SSLWRITE);
    	while(<SSLREAD>) {
    	     push(@reply,"$_");
    	}
    	close(SSLREAD);
    	return(@reply);
    }
    
    sub encode_base64 ($) {
    	my $res = "";
    	my $eol = "\n";
    	pos($_[0]) = 0;
    	while ($_[0] =~ /(.{1,45})/gs) {
    		$res .= substr(pack("u", $1), 1);
    		chop($res);
    	}
    	$res =~ tr/` -_/AA-Za-z0-9+\//;
    	my $padding = (3 - length($_[0]) % 3) % 3;
    	$res =~ s/.{$padding}$/"=" x $padding/e if $padding;
    	if (length $eol) {
    		$res =~ s/(.{1,76})/$1$eol/g;
    	}
    	return $res;
    }
    
    sub msglog {
            my($msg)=@_;
            my $time=time;
            my $localtime=localtime($time);
            print "\[$localtime\] ($0) " . $msg . "\n";
    }
    (There's also a small typo in this script: )
    Code:
    msglog("Could not connect to cPGSD on 127.0.0.1 to check running statis for $user $game $srvn");
    And while having the CPGS daemon down for a short period where I was rotating the cpgsd.log files (which would be a nice feature idea by the way ), I also noticed a problem with the cpgs_cron.pl script:

    Code:
    # if we get this far, we didn't find cPGSD running already
    
    $ret = system("/usr/local/cpanel/libexec/cpgsd.pl 2>\&1 >/dev/null");
    This is obviously the path for the cpgsd on the WHM/cPanel server, but not for the remote servers.
    Jayson

  2. #2
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    Good catch, that is just about the exact fix I have in 0.7.3 .
    The remote servers *should* have the /usr/local/cpanel/bin/ path created by cPGS for the sake of consistency with /var/cpanel/cpgsd.pl being a symlink back to it. Are you seeing /var/cpanel/cpgsd.pl being it's own file on the remote servers ?
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  3. #3
    Member
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    10

    Default

    Quote Originally Posted by darren View Post
    Good catch, that is just about the exact fix I have in 0.7.3 .
    The remote servers *should* have the /usr/local/cpanel/bin/ path created by cPGS for the sake of consistency with /var/cpanel/cpgsd.pl being a symlink back to it. Are you seeing /var/cpanel/cpgsd.pl being it's own file on the remote servers ?
    [root@games3 ~]# ls -a /usr/local/
    . .. bin etc games include lib lib64 libexec sbin share src
    We haven't done a complete reinstall since the first installation (which would have been in the 0.6 version branch), and I can't see any reference to creating the /usr/local/cpanel path in cpgsd.pl.
    Jayson

  4. #4
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    In cpgsd.pl, in sub updateself which is called out to remotes during updates it will keep it in /var/cpanel/ , using the install script manually will put it in /usr/local/cpanel/bin and symlink it back for backwards compatibility. Typically binaries aren't best put on /var/ ( something my boss reminded me of so I'll try to get the updateself routine to move it over as well to avoid the discrepancy.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

Similar Threads & Tags
Similar threads

  1. TS3 updating problems
    By redwood in forum cPGS Discussions
    Replies: 1
    Last Post: 09-27-2010, 02:31 PM
  2. Problems updating?
    By PDW in forum cPanel and WHM Discussions
    Replies: 12
    Last Post: 04-03-2009, 03:14 PM
  3. problems after updating to mysql 5
    By flamesburn in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 06-12-2007, 10:28 PM
  4. Problems after updating to C150
    By dball in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-22-2005, 07:33 PM
  5. Problems updating MySQL
    By woolly in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 05-09-2005, 02:06 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube