In this article we will cover the main prerequisites for successfully creating running a censhare server locally using Chocolatey. The full list of prerequisites and other dependencies can be found here.

Prepare the environment

  • Install Chocolatey from Chocolatey:
  • Install git:

    choco install git

> Note: Make sure to add the git command line path into the environmental variables of the system by following the steps below:
>
> 1. Go to My Computer > C:/Program Files/Git/cmd and copy the path
> 2. Go to My Computer > Properties > Advanced > Environmental Variables
> 3. Select the variable Path and click on the Edit button
> 4. Add the path to Git cmd, separated by a semicolon(;) from any existed paths
> 5. Click on OK and start a new Powershell
* Install yarn for managing node dependencies:

```bash
choco install yarn
```
  • Install Java11:

    choco install jdk11

    • Set JAVA_HOME:
      • Right click My Computer and select Properties.
      • On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located.
  • Install Ant:

    choco install ant

    • Set ANT_HOME:
      • Right click My Computer and select Properties.
      • On the Advanced tab, select Environment Variables, and then edit ANT_HOME to point to where the ANT software is located.
  • Install node.js:

    choco install nodejs

  • Select a Database solution:

    • In this article we are working with PostgreSQL, which can be installed from here

Configure the Git access and get the project sources

1. Git configuration

  • Configure your git username and email in order to be identified in the public repository:

    git config --global user.name "<Your Name> <Your Surname>"
    git config --global user.email "<your-username>@censhare.com"

  • Set the following Git options to avoid paths problem:

    git config --global core.longpaths true
    git config --global core.autocrlf true

2. Create a new local git repository

If you do not already have a local censhare git repository, you need to clone the remote repository.

  • Create a new directory for the source files and clone the remote repository in it:

    mkdir DIR_NAME
    git clone https: //git .censhare.com /censhare/censhare-product DIR_NAME\censhare-product

    Replace the DIR_NAME tag with the directory name of your choice.

  • Checkout the source files:

    cd DIR_NAME\censhare-product

  • Optionally setup a git GUI tool (WebStorm or a new bookmark in SourceTree)

3. Create a new working directory from an existing local repository Optional

If you already have a local censhare git repository on your disk, use the git-new-workdir script to get the source files for the current version. This will save your disk space.

  • Save the file git-new-workdir locally on an easily accessible location (YOUR_SCRIPT_FOLDER).

git-new-workdir script for Windows

  • Go to the parent folder of the existing FOLDER_FOR_CENSHARE_REPOSITORY, PARENT_FOLDER_FOR_CENSHARE_REPOSITORY.

    cd PARENT_FOLDER_FOR_CENSHARE_REPOSITORY

  • Execute the script (FOLDER_FOR_CENSHARE_REPOSITORY_BRANCH - name of newly created folder):

    YOUR_SCRIPT_FOLDER\git-new-workdir FOLDER_FOR_CENSHARE_REPOSITORY FOLDER_FOR_CENSHARE_REPOSITORY_BRANCH BRANCH_NAME
     
    For example, for the 5.4 release version it could look like (git-new-workdir was stored in PARENT_FOLDER_FOR_CENSHARE_REPOSITORY):

    .\git-new-workdir censhare-product censhare-product.5.4 release\5.

    • The script creates a linked repository directory named FOLDER_FOR_CENSHARE_REPOSITORY_BRANCH.
    • BRANCH_NAME examples: release/5.7, release/5.8, develop. Run git branch to list available local branches.
  • Optionally setup git GUI tool.

4. Add the git hooks

Copy the git hooks to the .git folder automatically, by simply executing one of the following commands:

censhare-Server /bin/build .bat copy.git-hooks

or

censhare-Server /bin/build .bat init

More details on git hooks can be found here.

Build the project

  1. Go to your project’s folder:

    cd \DIR_NAME\censhare-product\censhare-Server\

  2. Build project:

    bin\build.bat clean init jar


3. Download and unzip the patch_files.zip file.
4. Copy the files launcher.patch and server.SERVER_NAME.patch to DIR_NAME\censhare-product\censhare-Custom\censhare-Server\app\config\. Create a config folder if it is not present in the app/ directory.

Replace the SERVER_NAME tag with the name of your choice for the server, in the following:

  • The name of the server.SERVER_NAME.patch file and from its contents
  • Depending on the editor of your choice, quotes (“…”) in both files can be converted to curly quotes (“…”), which might cause issues on the server startup. Therefore, make sure that the quotes in both files are set as expected.

Create database

  1. Download the PostgreSQL graphical installer
  2. Run the installer to install PostgreSQL and create a master user and password for managing Postgres.
  3. As soon as Postgres is successfully installed, created your censhare tablespace, by executing the command below:

    psql -U postgres -f \DIR_NAME\censhare-product\censhare-Server\database\postgresql-create-user.sql

  4. Create the database structure:
    • Please note that postgresql-create-db.sql does not come from the git repo, instead it is created by building the censhare-Server with bin/build.bat init.

    psql -U corpus -W -d corpus -f \DIR_NAME\censhare-product\censhare-Server\database\postgresql-create-db.sql

    By default, this script creates a tablespace with username & password = corpus.

Finally, add your database configuration in the custom area, by copying the file config.SERVER_NAME.patch from the patch archive, to DIR_NAME\censhare-product\censhare-Custom\censhare-Server\app\services\database\. Create folders services and database if necessary and change the tag SERVER_NAME to your desired server name.

Depending on the editor of your choice, quotes (“…”) in both files can be converted to curly quotes (“…”), which might cause issues on the server startup. Therefore, make sure that the quotes in both files are set as expected.

Install the Image-Service-Tools

To install the relevant packages and fonts for the image-service, we encourage you to create a ticket to Service Desk, who will provide you with the needed packages and instructions. For any additional questions, you can always post on the #dept-dev-all channel on slack.

Start the local censhare server

  1. Run server:

    bin /StartServer .bat SERVER_NAME

  2. Open the server logs in text editor of your choise. The server logs can be found under DIR_NAME/censhare-product/censhare-Server/work/logs/server-0.0.log

Build and run the censhare Admin Client

  1. Build the Admin Client on your local machine:
  • Windows 32bit:

    bin\build.bat clean init jar release.win32

  • Windows 64bit:

    bin\build.bat clean init jar release.win64

  1. Copy the hosts.xml file to C:\Users\<windows-username>\censhare\hosts.xml
  2. Run the Admin Client
  3. Go to Configuration → Services → Module service → Configuration
  4. Check Development Mode and enable the TypeScript compilation option
  5. Write “node” (without quotes) in NodeJs command, press OK button TODO @kko I am not sure is “node” is correct on windows
  6. Open the Server actions menu (gear icon ⚙️   on the top panel) → Synchronize module assets
  7. Choose the required and optional checkboxes, press the OK button
  8. Open the Server actions menu (Gear icon on top panel) → Update server configuration , press OK button. Press OK on next step if needed.

Access censhare Web

  1. Access censhare Web in your browser: https://localhost.censhare.com:9443/censhare5/client/
  2. After ensuring that censhare Web works fine, uncomment lines 11-13 in \DIR_NAME\censhare-product\censhare-Custom\censhare-Server\app\config\launcher.patch. This will allow the automatic database updates to be executed on server start up.

Troubleshooting

If something does not work properly ask your colleagues, or post an open question to the #dept-dev-all channel in Slack.