API Reinstall
API Reinstall
Reinstalling Club Speed API
This is a guide to walk you through reinstalling API on a controller. This is usually done when there are some problems occurring with the Apps that normal troubleshooting isn’t fixing. You MUST only do an API reinstall as a last resort. Please confirm with Level 2 before scheduling an API reinstall. Lastly, this should only be done when the track is done for the day.
Before we proceed, there are a few assumptions we need to operate on while doing an API Reinstall
They should have the following installed already:
- PHP version updated to the latest supported version. (Ask a level 2 or leadership which version this is)
- PHP manager for IIS
- Microsoft Visual C++ 2010 Redistributable Package (x86)
- Git 2.16.2-64-bit.exe (https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/Git-2.16.2-64-bit.exe)
- Node v6.11.3 x64
You can verify this by looking at the programs and features on the server. All necessary installers will be attached in this article.
It is recommended you test an API Reinstall on a VM first, successfully, before deploying on a live server
Also, If a location has custom registration, screens, and other images they use for their sites, you will have to bring them over as well. You can find them in c:\clubspeedapps\assets
Install the newer dependencies
These will likely be installed already. Confirm that they are already installed and install them if they are not.
- rewrite_amd64_en-US.exe
- PHPManagerForIIS-1.3.0-x64 - IIS 8.msi – Use defaults (version number may vary depending on the version of windows server)
- vcredist_x86.exe
- msodbcsql.msi
- Git-2.16.2-64-bit.exe – select the “Use Git from the Windows Command Prompt” option when available. Other than that, use defaults.
- Node-v6.11.3-x64.msi – Use defaults
Stop Clubspeedapps
- Stop Gridding and Clubspeedapps auto update service in Firedaemon.
- Stop IIS
- Log off all SCR and REG users.
- End all processes that have anything to do with IIS (fast cgi, node.exe, w3wp, scr, etc. Ask L2 if not sure).
- Close out any windows where clubspeed apps related stuff is open (configs, screens, etc)
- Rename ‘Clubspeedapps’ to ‘clubspeedapps-old (enter date here)’.
- This will let you run the installer to create the new clubspeedapps folder. If you are unable to rename the folder, it is likely because there is a program still using clubspeedapps somewhere running.
Execute the Main Installer Batch File
- If you don’t already have the C:\\clubspeedinstaller on the server, download it please and extract it to the C drive.
- Go to c:\clubspeedinstaller, double click to run install file, press enter to run install.bat
- Hit enter when prompted. At the end of the installer, a private API key will be randomly generated. Copy it (right click, select Mark, drag over the region, and right-click) and paste it into Notepad. You'll need it later.
- If it closes out on you, go to passwords-generator.org
- Password Length: 20 characters
- Include Symbols: Un-select!!!
- Generate Password
Update Private Key, Configurations, and Stored Procedures
- Go to c:\clubspeedapps\api and open config.php in Notepad.
- Set the $privateKey [currently set to rand() . Time() ] to the private key generated above, wrapped by single quotes. Ex. $privateKey = '498298e9adsjdas9d0asoke';
- You must have the single quotes around it.
- Change the $dateFormat (defaults to 'Y-m-d') if necessary.
- Change the default time zone if necessary.
- Copy any ACL keys for integrations from the old config.php file in the API folder.
- Go to c:\clubspeedapps\cs-registration\laravel\app\config and open config.php in Notepad.
- Like above, set the privateKey to what you did earlier, replacing 'SHOULD_MATCH_API_CONFIG'.
- You must have the single quotes around it.
- Go to c:\clubspeedapps\api, and double-click install.sql. You'll most likely have to double-click it again after SQL Server opens. Once the script is open, execute it.
- (Hint: If you are doing this at a track that uses private keys for marketing or other custom dev work, you can always copy over the old config files by going into the folders of each app and copying over the config.php)
- EX: for API, go to c:\clubspeedapps-old\api and copy the config.php file.
- Paste it into c:\clubspeedapps\api (Backup the old one)
- Do this for all sites.
- You will need to copy the web.config file over from the phpconfig folder inside the clubspeedinstaller folder. (This is really important, reach out to L2 if you have questions regarding this step.)
- Navigate back to C:\clubspeedinstaller folder
- Open PHPconfig folder
- Copy all folders
- Navigate back to C:\clubspeedapps
- Paste & override old files
- admin, api, cs-registration, booking
Copy over Assests
- Navigate to the old clubspeedapps folder
- Copy the assets folder
- Navigate to the new clubspeedapps folder
- Paste the assets folder and accept overwriting existing files
Check FastCGI settings in IIS
- Open IIS and Expand the server name in the left pane.
- Expand Sites > Default Web Site > API
- Double click PHP Manager in the middle pane.
- We need to make sure the new version of PHP is installed and working. If not, we will register the PHP again.
- If you see “Manage All Settings” available in this page, we should be good. Otherwise, do the following.
- Follow the article to install and update PHP before moving on. The article can be found here: https://support.clubspeed.com/en/support/solutions/articles/47001101629-updating-php-in-iis
- Start IIS!
- Start IIS!
Make sure the following Firedaemon services are running.
- Clubspeedapps Auto Updater
- Gridding service
- Test gridding by typing the following in CMD and hitting enter.
- cd c:\clubspeedapps\event-builder\curl && curl -i -X POST -H "Content-Type: application/json" -d "{ \"participants\": [{\"name\":\"Wes\",\"points\":5,\"bestAverageLaptime\":31,\"bestLaptime\":35.234,\"startingPosition\":3,\"finishingPosition\":5},{\"name\":\"Glenda\",\"points\":3,\"bestAverageLaptime\":33,\"bestLaptime\":33.234,\"startingPosition\":2,\"finishingPosition\":4},{\"name\":\"Max\",\"points\":3,\"bestAverageLaptime\":35,\"bestLaptime\":33.536,\"startingPosition\":1,\"finishingPosition\":3},{\"name\":\"Tommy\",\"points\":2,\"bestAverageLaptime\":34,\"bestLaptime\":36.234,\"startingPosition\":4,\"finishingPosition\":2},{\"name\":\"Shakib\",\"points\":0,\"bestAverageLaptime\":32,\"bestLaptime\":31.234,\"startingPosition\":5,\"finishingPosition\":1}], \"options\": { \"maxDrivers\": 3 } }" http://127.0.0.1:8000/grid/bestLapTime
- If you see “HTTP/1.1 200 OK”, everything is well.
Now, Run API Migrations
http://localhost/api/migrations/
- TIP: Add LinkClump Extension to Chrome
Start Testing the Apps
- To test the sites, go to the links and replace * with the server's correct subdomain (LicenseName).
- API: http://*.clubspeedtiming.com/api/
- If there's data: http://*.clubspeedtiming.com/api/index.php/races/fastest.json?range=week&key=cs-dev
- cs-speedscreen: http://*.clubspeedtiming.com/cs-speedscreen/#/scoreboard
- mobile: http://*.clubspeedtiming.com/mobile/
- If there's data: http://*.clubspeedtiming.com/mobile/#/livetiming/fastestTimeByWeek
- cs-registration: http://*.clubspeedtiming.com/cs-registration
- Make sure you can complete registration. sp_admin settings may need changing.
- admin: http://*.clubspeedtiming.com/admin
- Log into the site using the support login. Go to the Speed Screen → Channel Editor section and play around with the preview links.
- Go to booking and click on settings.
Troubleshooting (Taken from the Original API Installer Documentation, most may not be needed)
- If you are unable to log into /admin, go to the following link. http://SERVER_NAME.clubspeedtiming.com/api/index.php/users/login.json? username=support&password=SUPPORT_PASSWORD_HERE
- If you see:
- {"error":{"code":500,"message":"Internal Server Error: could not find driver"}}
- Make sure that you extracted SQLSRV32.EXE to the /ext folder.
- Also try restarting IIS at the root level, not just the /api website.
- If you end up with a “HTTP Error 403.14 – Forbidden!”
- The Default Document is not set on some servers. Select your application in IIS (it's most likely cs-speedscreen or mobile), then double-click Default Document. Add “index.html” (notice how “index.htm” is there already, but not .html) and it should work now.
- If you get a “Connection Refused” Error when testing Gridding Service, do the following:
- Navigate to c:\clubspeedapps\event-builder in a Command Prompt, and type “npm install”.
- If you don’t see images when testing cs-registration
- This is because the track's network isn't configured to allow them to access their clubspeedtiming URL internally. A workaround: Copy/paste the c:/clubspeedapps/cs- HYPERLINK "file:///c:/clubspeedapps/cs-registration/images"registration/www/images folder into c:/clubspeedapps/assets/cs-registration.
- Logging into /admin results in an error that it can't resolve the site!
- This is because the track's network isn't configured to allow them to access their clubspeedtiming URL internally. A workaround: Go to c:\clubspeedapps\admin\laravel\app\config\config.php and change all occurrences of $_SERVER['HTTP_HOST'] to 'localhost'. The single-quotes are important!
- Help! I'm having to do a manual install of a Laravel app on the server!
- This can happen if the server had its API installed prior to the app having existed. First, open up IIS, expand out Sites → Default Web Sites, right click Default Web Sites, and click Add Application. For its name, type whatever other servers use (“admin” or “booking”), and choose the “www” folder within that project as the root directory.
- Then, ensure PHP is enabled for the site, make sure cgi.fastimpersonate is set to 0, and go to the URL Rewrite section of that project in order to import the .htaccess file (in the /www folder) and save those rules.
- Another Quick Fix
- Go to C:\Windows\System32\inetsrv\config and make a copy of the applicationhost.config file at that directory. Delete the original.
- Go to the doc folder in the clubspeedinstaller folder and copy the applicationhost.config file into the above directory
If there are any more questions please direct them to L2 or Management
Legacy clubspeedinstaller files:
- Here is a link for 2008 Servers: https://drive.google.com/file/d/1TSJSLL94R4aoYLy54BdIebjMfDm1egYH/view?usp=sharing
- Here is a link for 2012 Servers: https://drive.google.com/file/d/1xuisr_rat3c24h5DqIdqrcyvBZO2Ko5n/view?usp=sharing