-
Notifications
You must be signed in to change notification settings - Fork 24
WISE Local Development using Windows Subsystem for Linux (WSL)
Follow the instructions here: https://docs.microsoft.com/en-us/windows/wsl/install-win10. (I'm using Ubuntu from the Windows Store for my Linux distro.)
Depending on your version of Windows, your system may support WSL 2, which includes a native Linux kernel and significant performance improvements. Follow the instructions in the above link to use WSL 2.
Start the Linux distro and complete initialization (if you haven't already done so): https://docs.microsoft.com/en-us/windows/wsl/initialize-distro.
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install default-jdk
Set JAVA_HOME.
First, identify the path to your Java install:
$ update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure.
Your output may vary depending on your Java installation. Run sudo vim ~/.bash_profile
(or swap vim for your favorite text editor), add following to the file (replacing with the path to your Java installation), and save and quit:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Reload the terminal or set JAVA_HOME for the current session:
$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
$ sudo apt install maven
$ mvn -v
You should see output similar to:
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.19.104-microsoft-standard", arch: "amd64", family: "unix"
The following steps follow these instructions for install Node using nvm: https://gist.github.com/noygal/6b7b1796a92d70e24e35f94b53722219.
$ sudo apt-get install build-essential
# Check nvm for lastest version (using 0.35.1 in this example)
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
I had to update my bash profile to get nvm to load correctly each time bash is started. Run sudo vim ~/.bash_profile
(or swap vim for your favorite text editor), make sure the following is added to the file, and save and quit:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Reload the terminal or run the following for the current session:
$ export NVM_DIR="$HOME/.nvm"
$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
$ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Then run:
$ nvm install --lts
$ nvm use --lts
$ echo "nvm use --lts" >> .bash_profile
Run node -v
and npm -v
to verify installation.
Instructions for Ubuntu: https://redislabs.com/blog/redis-on-windows-10/ (may vary slightly depending on your Linux distro).
Once Redis is installed and running (sudo service redis-server start
), run redis-cli config set notify-keyspace-events Egx
$ sudo apt install git
$ git clone https://github.com/WISE-Community/WISE.git
$ cd WISE
# install node dependencies
WISE $ npm install
WISE $ chmod u+x wise.sh
Install MySQL and start service
WISE $ sudo apt install mysql-server
WISE $ sudo service mysql start
Create WISE database and user:
# login as root (or set a password for root user and run `mysql -u root -p`)
WISE $ sudo mysql
# create new user wiseuser, password wisepass
mysql> create user 'wiseuser'@'localhost' identified by 'wisepass';
# create wise_database
mysql> create database wise_database default character set=utf8;
# give wiseuser access to the new database
mysql> grant all privileges on wise_database.* to 'wiseuser'@'localhost';
mysql> flush privileges;
mysql> exit;
Create tables for wise_database by reading in the src/main/resources/wise_db_init.sql file:
# create tables for wise_database and load it with initial values
WISE $ mysql wise_database -u wiseuser -p < src/main/resources/wise_db_init.sql
WISE $ cd ~
$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$ sudo apt install ./google-chrome-stable_current_amd64.deb
I had to update my bash profile to get ChromeHeadless (which is used for WISE unit tests) to run on WSL. Run sudo vim ~/.bash_profile
(or swap vim for your favorite text editor), add the following to the file, and save and quit:
export CHROME_BIN=/usr/bin/google-chrome-stable
Reload the terminal or set CHROME_BIN for the current session:
$ export CHROME_BIN=/usr/bin/google-chrome-stable
Create a startup script:
$ touch startup.sh
$ chmod u+x startup.sh
$ vim startup.sh # or use your favorite editor
Add the following to your startup.sh
script and save the file:
sudo service redis-server start --daemonize yes; sudo service mysql restart;
Invoking sudo
commands from the Windows command line requires typing your Linux password. To avoid having to do this on startup, you can edit your sudoers
file.
- Run
sudo visudo
. - Paste the following to the bottom of the file and save (replacing
username
with your username):
username ALL=(ALL) NOPASSWD:ALL
- This tells Linux to not require a password anytime your user runs a
sudo
command.
Create a Windows Task to run the startup script on boot:
- Open the Windows Task Scheduler
- Choose "Create Basic Task"
- Give the task a name ("WSL startup", for example)
- For Trigger, choose "At log on"
- For Action, choose "Start a program"
- For Program/script, input "C:\Windows\System32\bash.exe" or click "Browse" and find "bash" in your Windows\System32 folder
- In the "Add arguments" field, enter
-c "/home/{username}/startup.sh"
, replacing {username} with your WSL user - Save the task
You can test the startup script by doing the following:
- In Linux, stop MySQL and Redis:
$ sudo service mysql stop
$ sudo service redis-server stop
- Run the startup task in Task Scheduler by right clicking on the task and selecting "Run"
- Go back to Linux and check to see that MySQL and Redis are running:
# Test that Redis is running.
$ redis-cli
# You should see the Redis command line. Type 'ping' and press Enter.
127.0.0.1:6379> ping
# You should get this response:
PONG
# Exit the Redis cli.
127.0.0.1:6379> exit
$
# test that MySQL is running
$ sudo mysql
# You should see the following output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.20-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# Exit MySQL.
mysql> exit;
$
Create an application properties file from the supplied sample properties file.
$ cd WISE
WISE $ cp src/main/resources/application_sample.properties src/main/resources/wise.properties
You can then edit any settings in the properties file for your local installation. [TODO: link to application.properties
details/instructions.]
Build the applications and start WISE:
# This builds a development environment. To build a production environment, use `npm run build-prod`.
$ npm run build-dev
# Start WISE
WISE $ ./wise.sh run
$ npm install -g @angular/cli
Open VS Code in you WISE directory
# In the WSL command line, navigate to your git WISE folder that you previously cloned
$ cd WISE
# Open VS Code using the current directory
WISE $ code .
Install the Java Extension Pack
- Go to the Extensions view (Ctrl+Shift+x)
- Search for Java Extension Pack
- Click on the Java Extension Pack
- Click the Install button
- You may need to restart VS Code after the extension is installed
Run Maven Compile
- Go to the Explorer view (Ctrl+Shift+e)
- In the Explorer window you should see a tab for MAVEN PROJECTS
- Expand the MAVEN PROJECTS tab, you should see the wise project in it
- Right click on the wise project and then click compile
Build the client application
- Run the command below in the command line. This may take a minute to build the client application and run the tests.
WISE $ npm run build-dev
- The tests finish running when you see something like this
HeadlessChrome 83.0.4103 (Linux 0.0.0): Executed 387 of 387 SUCCESS (3.83 secs / 2.885 secs)
TOTAL: 387 SUCCESS
Run the WISE server application
- Go to the Explorer view (Ctrl+Shift+e)
- Find the Application.java file, it should be located at src/main/java/org/wise/Application.java
- Right click on it and click Run (or Debug)
- In the VS Code Terminal you should see output showing Spring Boot starting up.
- If WISE has started up properly you should see something like "Started Application in 7.502 seconds"
- Go to your web browser and go to http://localhost:8080/