/
Startup scripts for cloud apps

Startup scripts for cloud apps

Introduction

Atlassian connect apps require server instance to deploy the backend to communicate to in order to fetch the data and show them in the front end(Atlassian cloud app). Backend also helps in calling the backend cloud Jira(or other Apis of Atlassian) to perform certain tasks on Atlassian app instances. For this to work though we need to keep the backend server always up and running. Atlassian also checks for the readiness of the app by requesting for the descriptor file at regular intervals of time and if found that the app is down a mail is triggered to the marketplace account admin.

Problem Statement

Whenever we start the vm instance and then start our apps manually we attach these application processes to the process of the currently logged in user in the VM instance. in such cases whenever the user logs off all the user process associated with that user(Including the apps running) are terminated.

Probable Solution

We have to make sure that we attach the application process to the system startup and not to any user so that whenever the vm instance is started the apps on that instance are automatically booted up and are ready to serve the requests

Process

Process to create new startup script for Nodejs apps -

  • Create a empty .bat file(text file with .bat extension)(Windows)

  • Add the statements to perform following actions in the .bat script

  1. Change the current directory to the root of the project

  2. Set the required environment variables(including the local base url)

  3. Script to start the application

  4. “Pause“ to keep the app running

Process to create new startup script for Spring boot apps -

  • For Spring Boot apps, we can run all the apps inside tomcat container and then start the tomcat container using the below script which will start the other apps running in the container

For running Nginx server using script we can do the following,

All of the above scripts are independent of each other in other words their order of execution doesn’t matter

Process to add the script to startup - (Windows Server 2008 R2 data center)

  • Go to task scheduler under Computer Management

 

 

 

 

 

 

 

 

 

 

  • Create a Task by clicking on “Create Task“ in the right click menu, There will be a dialog with different tabs. Please make sure that the options selected in each tab is same as the one shown in the snapshots below

General Tab

Triggers Tab

In the triggers tab click on “New“ button and create a new trigger as follows and click ok, Please remember to select “At Startup“ option for “Begin the task” dropdown menu.

Actions Tab

Click on “New“ button and select action as “Start a program' and in the setting select the .bat file that we created in the previous step.

Conditions Tab

In the Network section select the primary network for the machine to be used. If this is configured in properly then the script will not start. For the scripts to start network is required. If the script is started before the network boots up then the script will throw the errors and will stop working

Settings Tab

Make sure that the selected options are same as the ones selected below

After clicking on “Ok“ button the tasks should now be listed in the “Active Tasks” list of the Task Scheduler

Please remember that if for some reason the scripts are not starting at startup please check the Windows Event Viewer to see for any logs of errors.