====== Intellij IDEA - Setup of Ticketer dev environment ====== Original Creator : --- //[[anna.dowling@errigal.com|Anna Dowling]]// Updated by : --- //[[colm.carew@errigal.com|Colm Carew]]// Updated by : --- //[[oleksandr.kononov@errigal.com|Oleksandr Kononov]]// Updated by : --- //[[conor.giles@errigal.com|Conor Giles]]// ===== DB and Appfile Setup ===== Unfortunately there are a lot of steps here but there is an easy way and a hard way, the easy way only applies to CC and EXT DBs for now so if you need DBs/Appfiles for a different customer you will have to do it the hard way. For either method, you need to create an appfiles directory first. === Appfile Setup === If you are on MacOS Catalina, the method is different from earlier versions, or on linux. If you are not on Catalina, you can run the following commands and skip the next part marked 'Catalina Setup'. == Normal setup == * sudo mkdir -p /export/home/scotty/appfiles/ * sudo chown -R $(whoami) /export/home/scotty == Catalina Setup == Apple's new [[https://support.apple.com/en-gb/HT210650|APFS]] prevents you from writing anything directly to '/', so a workaround is needed to create our '/export' directory. We will achieve this using 'synthetic fixlinks', mapping a virtual directory on '/' to a directory on our writeable Data volume. First, we must create the directory on our Data volume: * sudo mkdir -p /System/Volumes/Data/export/home/scotty/appfiles * sudo chown -R $(whoami) /System/Volumes/Data/export/home/scotty Now, we create a synthetic.conf file which maps '/export' to our newly created directory. * sudo touch /etc/synthetic.conf * sudo chmod 644 /etc/synthetic.conf * sudo nano /etc/synthetic.conf Inside this file, add the following line: export System/Volumes/Data/export Note: The whitespace between export and System **must** be a tab.\\ Now restart the system to push the changes. ==== The Easy Way ==== * Clone the following two projects into the same folder (I suggest an applications folder or IdeaProjects folder) : * https://bitbucket.org/errigal/database-setup * https://bitbucket.org/errigal/env-configuration * cd into database-setup * Run the following command ansible-playbook -i ../env-configuration/prodext local.yml --diff --extra-vars "database=ticketer mysql_root_pass=THEDBPASS" --vault-id @prompt * Note that prodext can be replaced with prodatc if you want ATC data. The database is ticketer and ensure to change the root password to your local root password install * If you are running MySQL through docker you will need to run: ansible-playbook -i ../env-configuration/prodext local.yml --diff --extra-vars "mysql_path='docker exec -i CONTAINER /usr/local/mysql/bin/mysql' database=ticketer mysql_root_pass=THEDBPASS" --vault-id @prompt * You will need the password for this so also ask someone for that if you don't know it, Once done just leave it run and complete and it should download the DB and run development transforms as well as download the app files Note that some tickets reference the snmp_manager database. Installing this database is not strictly necessary, but can avoid errors when running. Install with the following command like above: ansible-playbook -i ../env-configuration/prodext local.yml --diff --extra-vars "database=snmp_manager mysql_root_pass=THEDBPASS number_of_traps_to_get=100000" --vault-id @prompt ==== The Harder Way ==== * Download a micro/small database from a customer and load it into your local MySQL instance. - note you will want to set your max allowed packet large for this mysql -uroot -p -e 'set global max_allowed_packet = 1000000000' mysql -uroot -p DB < db.dump * Run the Dev scripts on this database, they should be found in - https://bitbucket.org/errigal/idms-sql-script * Go to a customer app server and see what directory structure is present for the Ticketer and recreate locally in /export/home/scotty/appfiles ===== Import Prerequisites ===== - IntelliJ Ultimate Edition - Install **Grails 2.2.4** for Mac Install SDK Man http://sdkman.io/install.html and use it to install grails 2.2.4 (sdk install grails 2.2.4) - **MySQL 5.7** - use dbdb and the ansible scripts above to set up the DB - You will need to download **GWT 2.5.1** and keep it in a secure directory i.e. your user directory or your documents http://www.gwtproject.org/versions.html. Once downloaded you will need to set GWT_HOME to be the location of where you put the downloaded directory - Ensure you set GWT_HOME in your .bashrc or .bash_profile(for Mac) file as follows: export GWT_HOME=“~/gwt-location” - **Java 7.0.262** - sdk install java 7.0.262-zulu - **Groovy 2.4.3** - sdk install groovy 2.4.3 - Ticketer Project: - Clone project via git from [[https://bitbucket.org/errigal/ticketer/src/dev/|here]] =====Importing project to IntelliJ ===== Import Ticketer project as existing project and make sure you have **Grails 2.2.4** installed on machine and use that as the Grails option. Also make sure that you have Groovy 2.4.3 installed. Intellij should automatically detect this is a Grails project and allow you to select the correct version on the wizard setup page.☐ Go to Project Settings and make sure that you have the following dependencies set up: Make sure you have a log file with the following path /export/home/scotty/logs/grails/Ticketer.log **Usual Problems** - The same goes with GWT_HOME, ensure that GWT_HOME is set and can be accessed from within the IDEAJ terminal - set it in .bashrc or .bash_profile echo $GWT_HOME ===== Project Settings: ===== * **Project** SDK: Java 1.7 //(java 1.7.080)// * **Modules**: ticketed and ticketer-grailsPlugins - path to GWT installation directory need to be correctly set up here. * **Library**: GWT SDK (get-user) * **Facets**: ticketed and ticketer-grailsPlugins - path to GWT installation directory need to be correctly set up here. * **Artifacts**: ticketed and ticketer-grailsPlugins - GWT artifacts. ==== Platform Settings: ==== * **SDK**: Java 1.7 * **Global Libraries**: Groovy 2.4.3 and Grails 2.2.4. ===== 3. Running SQL scripts: ===== Not required but advisable to run scripts from mysql prompt. Run mysql -uroot -p command in your terminal to open mysql prompt, enter your password which ideally should be the Errigal Password Convention and run the following scripts **(copy and paste if using mysql prompt- order in which you run the scripts is important!)**: - Run the development transform scripts (located in ticketer/scripts/db/development_transform.sql) on your ticketed db - **make sure to change all emails**. - Run the appropriate upgrade scripts(located in idms-sql-script/upgrade/RELEASE_NUMBER/Ticketer_X_XX_X_upgrade.sql - at the time of setting up the ticketer, Ticketer_2_19_0_upgrade.sql was used) on your ticketed db - **make sure to change all emails!!!** ===== 4. Editing Run/Debug Configurations for ticketed (top nav bar) ===== {{:onboarding:advanced:editgrailsconfigurationforreportingmanager.png?300|}} {{:onboarding:advanced:reportingmanagereditinggrailsconfig.png?700|}} Add the following to your vmoptions, located in edit configurations: -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.ticketer.database=ticketer -Dgrails.server.port.http=8083 If needed to input jvm options from command line rather than idea: export GRAILS_OPTS="-Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.ticketer.database=ticketer -Dgrails.server.port.http=8083" ===== 5. Setting up logs for grails: ===== Run the following to create and own directory for grails logs: sudo mkdir -p /export/home/scotty/logs/grails/quite sudo chown user-name:staff /export/home/sudo chown user-name:staff /export/home/scotty/logs/grails/ touch /export/home/scotty/logs/grails/Ticketer.log ===== 6. Running project in IntelliJ: ===== * Run **cmd + alt + g** to access grails terminal * Run **clean** in grails terminal to clean the project. This wipes out gwt modules * Note; if you are using the DNS, you may come across issues with downloading dependencies(plugins) from the errigalArtifactory. To resolve this for now, we added the following to your /etc/hosts file as a workaround; * 23.23.106.9 errigalArtifactory * Run **compile** in grails terminal to compile the project. * Run **compile-gwt-modules** in grails terminal * Run the project using **^R** or **green arrow** in the top panel. {{:onboarding:advanced:grailscommandwindow.png?500|}} Note: If problems are experienced when compiling the project and/or gwt modules, try to clean your .grails cache by removing the Ticketer folder located in your ~/.grails/2.2.4/projects/ and run clean, compile, compile-gwt-modules again. Note: IF you are having issues running the application in Idea (especially on Linux) but its OK from the console and you are getting the error: "cannot invoke method getat() on null object" - start run-app with the "--stacktrace" flag to pinpoint the error which in my case was relating to: def versionNumber = currentGwtHome[-5..-1] being null in the BuildConfig.groovy. To fix this /etc/environment needs to have **GWT_HOME** set here as the .bashrc is sometimes not sufficient for other applications to pick it up * Unordered List ItemIf you using sudo to startup IntelliJ, try sudo -E /path/to/IntelliJ * -E, --preserve-env * http://stackoverflow.com/questions/8633461/how-to-keep-environment-variables-when-using-sudo ===== 7. Accessing application via web browser: ===== At this point your application should be up and running, navigate to http://localhost:8083/Ticketer/. Well done! ===== 8. Adding a user ===== If you are just running the ticketer locally and don't have access to any user management tools, you can use [[https://bitbucket.org/cgiles-errigal/ticketer_new_user/src/master/|this script]] to add a new ticketer user. Follow the instructions in the readme to quickly create a new user for exploring the workbench with.\\ Alternatively, you can do this process manually by doing the following: * Log in as the admin user * Select the admin panel from the workbench page * Select Users from the admin page * Click New User in the toolbar * Fill in the desired login details (for password, begin with {MD5} and paste in the result of running md5 -s "PASSWORD" on your machine * Save the user * Select the newly created user from the user list * Click the edit button * Assign visibilities, groups and roles to the user * Save the user again * Now log out and log back in as the newly created user