Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Sunday, 5 December 2010

Perforce Windows Service Fails to Start: Invalid Server IP

On a Windows machine with more than one network interface card (NIC), I see the Perforce service failing to start. When I check the Perforce log, I see a message like this:

Perforce server error:Licensing error -- invalid server IP address.bind: 10.1.1.218:1666: WSAEADDRNOTAVAIL

The Host IP Address Does Not Match the License

Confirm that the IP address in the license file matches at least one of the IP address on the server.

The license file is located in the Perforce server root directory. On 32-bit and 64-bit Windows systems the default location is:

C:\Program Files\Perforce\license

If running 32-bit versions of Perforce on 64-bit systems, then the default location is:

C:\Program Files (x86)\Perforce\license

If none of the server interfaces has an IP address matching the address in the file, then you need to obtain a new license file. Contact sales@perforce.com for more information on updating your Perforce license file.

Note: Changing the IP address by editing the license file will not work, as the license file uses a checksum digest to prevent tampering.

The Host IP Address Matches the License

If the Network Interface Card (NIC) is assigned an IP address by way of DHCP, or the Windows system is on a domain, the NIC initialization might be delayed. Windows will verify a single network interface has started before declaring the network to be in a running state. Because the NIC initialization is delayed, the local loopback network interface can trigger a network active signal. The NIC can have a self-assigned IP address which is unlikely to match the IP address located in the Perforce license file.

To confirm the problem, look in the Windows system event log for entries like this:

Source=DHCP, Type=Warning, EventID=1003: Your computer was not able to renew its address from the network (from the DHCP Server) for the Network Card with network address 001143D97C73. The following error occurred: The semaphore timeout period has expired. . Your computer will continue to try and obtain an address on its own from the network address (DHCP) server.Source=NETLOGON, Type=Error, EventID=5719: This computer was not able to set up a secure session with a domain controller in domain INTERNAL due to the following: There are currently no logon servers available to service the logon request. This may lead to authentication problems. Make sure that this computer is connected to the network. If the problem persists, please contact your domain administrator. Source=DHCP, Type=Warning, EventID=1007: Your computer has automatically configured the IP address for the Network Card with network address 001143D87C73. The IP address being used is 169.254.209.1.Source=Service Control Manager, Type=Error, EventID 7022: The Perforce service hung on starting.Source=Service Control Manager, Type=Error, EventID 7034: The Perforce service terminated unexpectedly. It has done this 1 time(s).

For more information on how to access the Windows system event log:

How to view and manage event logs in Event Viewer in Windows XP

Windows 7 - Open Event Viewer

Right now the only known workaround is to configure the Perforce Windows Service to restart if startup fails:

Select the Windows "Start" menu. Right-click on "My Computer" and select the "Manage" menu item. The Computer Management utility is started. Double-click on "Services and Applications". Double-click on "Services". You will now see a list of available Windows services. Scroll down until you see the "Perforce" service. Right-click on the Perforce service and select the "Properties" menu item. This will display the dialog for the Perforce service. Click on the the "Recovery" tab to display the Perforce service recovery options. Next to the "First failure" label there is a drop-down menu. Select "Restart the Service". Click the "OK" button to save the recovery option. Close the "Computer Management" window.

The Perforce service will now attempt to restart if the initial startup fails.


View the original article here

Saturday, 6 November 2010

Build P4PHP on Windows

How do I build P4PHP on Windows?

Note that this article provides further detail for the steps listed in the P4PHP release notes, which can be found in the following location:

http://www.perforce.com/perforce/doc.current/user/p4phpnotes.txt

In order to obtain a P4PHP binary for Windows, you will need to set up a PHP build environment. This article describes the necessary steps needed to set up such an environment, as well as instructions on how to build PHP and P4PHP using that environment.

Building P4PHP on Windows will require the following three things:

A properly set up build environment, including Visual Studio with the right SDK and some binary tools used by the build system.

Prebuilt libraries and headers for third party libraries that PHP uses, placed in the proper location in the build environment.

The P4PHP source (ftp://ftp.perforce.com/perforce/r09.2/bin.tools/p4php.tgz).

This is the hardest part of the PHP windows build system to set up and will take up a lot of space on your hard drive - you need to have several GB of space free.

Microsoft Visual C++ -- PHP officially supports building with Visual C++ 6.0 or with Visual C++ 9 (also known as Visual C++ 2008). You can use the Express versions as well. MinGW and other compilers are NOT supported or even known to work. For more information and how to get the compiler see the supported versions. This article supposes that you are using Visual Studio 2008 Express.  Make sure the compiler has been updated with the latest service patch (SP1 at the time of this writing.)

PHP/P4PHP can also be compiled with Visual Studio 2010, as it includes the VS9 compiler.

The correct Windows SDK or Platform SDK to match your compiler. See Supported Windows/Platform SDK for the supported versions. SDK 6.1 is the one used by Visual Studio 2008, but SDK 7 will work as well.

Various tools. See http://pecl2.php.net/downloads/php-windows-builds/php-libs/binary-tools.zip for binary versions of them. The libbind and pcre libraries are not required.

Get Visual Studio 2008 or 2010. You can use any of the commercial editions or the Express Edition.

Get and install windows SDK 6.1 or SDK 7.1

Get a PHP 5.3 snapshot (do not extract yet!)

Create the folder c:\php-sdk

Unpack the binary-tools.zip archive (http://pecl2.php.net/downloads/php-windows-builds/php-libs/) into this directory; there should be one sub-directory called "bin" and one called "script".

Choose Start -> Microsoft Windows SDK v6.1 -> CMD Shell, and then enter the following commands:

setenv /x86 /xp /releasecd c:\php-sdk\bin\phpsdk_setvars.batbin\phpsdk_buildtree.bat php53dev

Now, extract the snapshot from (3) to C:\php-sdk\php53dev\vc9\x86 with your unpacker of choice (WinRAR should handle it) so that the following directory gets created: C:\php-sdk\php53dev\vc9\x86\php-

In the same directory ( C:\php-sdk\php53dev\vc9\x86 ) there is a "deps" folder, extract any of your required libraries inside that folder ( see http://wiki.php.net/internals/windows/libs ), but make sure their top-level contains "/include" and "/lib" (some of them have an extra directory level in there). You can find the pre-compiled libraries that you need here:  http://pecl2.php.net/downloads/php-windows-builds/php-libs/ ( VC9 is Visual Studio 2008, remember - you do not need libbind or pcre ).

Run in the windows-sdk-shell:

cd C:\php-sdk\php53dev\vc9\x86\php-

buildconf - this will clear any existing configuration.

To get an overview of the compiling flags:
configure --help

Create your configure command:
configure --disable-all --enable-cli --enable-pdo (and use --enable- to enable any other desired extensions).
Warning: some extensions need libraries, header files and helper apps, see libs, fetch the version you need and extract the archive in the deps directory: c:\php-sdk\php53dev\vc9\x86\deps). You will need to enable --with-pdo to be able to create the default PHP.

Run nmake.

The compiled php is now under C:\php-sdk\php53dev\vc9\x86\php-\Release_TS.

Now that you have a build environment capable of building PHP, we can build the P4PHP extension. We will build P4PHP as a DLL that can be added to the PHP installation.

Map p4php to the directory C:\php-sdk\php53dev\vc9\x86\php-\ext\p4_php. Note the directory is "p4_php", not "p4-php". This is because "p4-php" is a macro variable, and using this as a directory name would break the build.

In the SDK shell, go back to C:\php-sdk\php53dev\vc9\x86\php-. Reset the configuration:

buildconf

Configure with the following options. ",shared" instructs the compiler to create a dll.

configure --disable-all --enable-cli --enable-pdo --with-perforce=,shared  

Run nmake

nmake

php_perforce.dll should now be in the Release_TS directory.

To test it, you can copy the dll into the "ext" directory of an existing php installation.

To enable PHP to actually use the dll, you need to either run php from the command line with the option php.exe -d extension=php_perforce.dll, or you can hard-wire it in the php.ini file in the php distribution. See Installation, below.

Once you have built PHP/P4PHP, you will need to install it. This involves three steps:

Copy the PHP release tree (The Release_TS directory) to C:\PHP5. This is the recommended location. It can be placed elsewhere, but then you will need to edit the php.ini file so that it can find its extensions.
Create a php.ini file in the C:\Windows directory, or copy (as Administrator) one of the php.ini files in the PHP source tree to C:\Windows\php.ini: C:\Windows\system32>copy C:\php-sdk\php53dev\vc9\x86\php-\php.ini-production C:\Windows\php.ini 1 file(s) copied.

Edit the php.ini file to add the line extension=php_perforce.dll

NOTE: You can skip this step if not planning on doing anything other than testing P4PHP. Creating/Editing a php.ini file is outside the scope of this document. Just use php -d extension=php_perforce.dll when loading your test scripts. Add the C:\PHP5 directory to the PATH variable. (Start Menu -> Control Panel -> System ->Advanced Settings -> Environment Variables)

You can perform some quick tests of P4PHP. Note that the Windows version of PHP does not support interactive mode, so you will need to write up a script and then run it.

Before you do that, make sure that php is in the PATH and that Perforce is being loaded.

C:\users\bruno\Documents\local>php -VUsage: php [options] [-f] [--] [args...] php [options] -r [--] [args...] php [options] [-B ] -R [-E ] [--] [args...] php [options] [-B ] -F [-E ] [--] [args...] php [options] -- [args...] php [options] -a -a Run interactively -c | Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f Parse and execute . -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -r Run PHP without using script tags -B Run PHP before processing input lines -R Run PHP for every input line -F Parse and execute for every input line -E Run PHP after processing all input lines -H Hide any passed arguments from external tools. -s Output HTML syntax highlighted source. -v Version number -w Output source with stripped comments and whitespace. -z Load Zend extension . args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin --ini Show configuration file names --rf Show information about function . --rc Show information about class . --re Show information about extension . --ri Show configuration for extension .C:\users\bruno\Documents\local>php -m[PHP Modules]CoredateeregpcrePDOperforceReflectionSPLstandard[Zend Modules]

If you see "perforce" listed in the modules then it is being loaded properly. Proceed to testing.

Place the following in a file named p4php_info.php.

identify());$p4->port = 'localhost:1666';$p4->user = 'bruno';$p4->connect();print_r($p4->run('info'));$p4->disconnect();?>

Now run p4php_info.php. You should see something like the following:

C:\users\bruno\Documents\local>php -f p4php_info.phpPerforce - The Fast Software Configuration Management System.Copyright 1995-2010 Perforce Software. All rights reserved.Rev. P4PHP/NTX86/2009.2/239532 (2009.2 API) (2010/03/24).Array( [0] => Array ( [userName] => bruno [password] => enabled [clientName] => test-ws [clientRoot] => c:\Users\bruno\Documents\local [clientCwd] => C:\Users\bruno\Documents\local [clientHost] => tombstone [clientAddress] => 192.0.0.1:1666 [serverName] => Bruno P4D [serverDescription] => Bruno test service [monitor] => enabled [security] => enabled [serverAddress] => Bruno:1666 [serverRoot] => C:\Program Files\Perforce\Server [serverDate] => 2010/03/29 15:09:00 -0700 Pacific Daylight Time [serverUptime] => 102:44:51 [serverVersion] => P4D/NTX64/2009.2/228098 (2009/12/16) [serverLicense] => none ))

View the original article here

Changing the Windows TEMP Directory

I have been hitting the Windows path length limit of 260 characters on my local workspace, but it is not the workspace root that is causing the problem. Instead, the error message indicates that the temporary file could not be created.


As noted in KB article #978, you can avoid most path length issues by moving the local workspace root to a shorter path. However this does not affect the current location of the Windows TEMP directory, typically located on the path: C:\Users and Documents\{user name}\local settings\tempBefore adding the user name this is a 43 character path. Adding a user name of 8 letters pushes this over 50 characters. The location of the temporary file directory is controlled by the operating system, as noted in the Perforce Command Reference. To set the Windows temporary directory location for a current DOS command prompt, you can to use the "set" command from the command prompt. For example: set TMP=C:\temp set TEMP=%TMP% Note: The temporary directory must already exist. The first command sets the value for %TMP%. The second verifies that the %TEMP% value is the same as %TMP% -- a mismatch of those two values can cause a variety of problems for anything that uses the temporary directory. To permanently set the temporary directory for a Windows user account, go to Control Panel->System->Advanced, and enter the "Environment Variables" dialog window to find and change the TEMP and TMP variable settings in the "User variables".

View the original article here