How to deploy a service & daemon



Manual Service Deployment


You can deploy a service manually using your terminal. Your service eventually resolves to a NodeJs code and to run this code, all you need to do is specify some environment variables then use node to.

The following snippet provides an example on how to manually deploy a service.

Service Manual Deployment
# Go to folder where service was created
cd /opt/soajs/node_modules/myService
 
# start the soajs example environment
sudo soajs services start --env=[ENTER THE NAME OF YOUR ENVIRONMENT HERE]
   
# export necessary environment variables to create local awareness
export SOAJS_ENV=[ENTER THE NAME OF YOUR ENVIRONMENT HERE]
export SOAJS_SRVPORT=[ENTER THE PORT]
export SOAJS_DEPLOY_MANUAL=1
export SOAJS_REGISTRY_API=[ENTER THE GATEWAY IP and maintenance PORT]

# Deploy service
node .



Dashboard Service Deployment


If you installed the SOAJS Dashboard, you can deploy your custom service using the UI following these steps:

Step 1: Link to GIT & Activate your service/daemon

Head to the Develop pillar â†’ Repositories and link your Bitbucket/Github account to the dashboard.

Once linked, browse through the list of repos and activate your service:



Step 2: Deploy the service/daemon

Services must be deployed in an environment, so we need to deploy the environment, then deploy the service in it. Check out the Clouds & Deployments to learn how to deploy an existing environment or check out Registries to learn how to create and deploy an environment.

Once your deploy the environment, proceed with the service:

  1. Go to Repositories under Deploy pillar
  2. Click on the service/daemon you want to deploy and click on Configure Deployment
  3. Choose which branch you want to deploy the service/daemon from
  4. Specify the memory limit per instance
  5. Specify the CPU limit per instance
  6. Choose the Catalog Recipe
  7. Choose the deployment mode
  8. Enter how many replicas you want to deploy(usually for local deployment 1 instance is enough), or turn on Auto Scale then enter the cpu percentage, the minimum and the maximum replica count(only for services).


    Repeat these steps for any additional service/daemon you want to deploy



Grant Access to Owner


After deploying your services in an environment, you need to grant access to it, click here to learn how to secure your service when you are done deploying it.



Dashboard Daemon Configuration


Daemons require groups to be deployed and daemon groups are managed under the Develop pillar. Make sure you have SOAJS Dashboard installed so you can create and configure a daemon group.


Log in to the Dashboard, and activate the git account that contains your daemon.

Go to Develop → Repositories and add your git account, then activate the repo that contains your daemon.

Now head over to Develop â†’ Daemon Catalog and you will see your daemon in the Daemons tab.

Create a Group, configure it and assign it to our daemon.

The group configuration is what drives our daemon: It specifies when the daemon should run, how long it should run for, how to execute its jobs, etc...

Click on the Group Configurations tab and click Add Group Configuration.

Here you will enter the group name of your choice, select your daemon from the drop down menu, select what type of daemon you want (interval, cron, or run once), and whether or not you want the daemon jobs to run sequentially or in parallel.

Once this is done, our demon is ready to be deployed!



Daemon Deployment with Manual SOAJS Deployment


Similar to manually deploy a service, you can deploy a daemon using your terminal.

Daemons behave like services in SOAJS and require the same list of environment variables.

In addition they need to know which group configuration to load thus an additional environment variable should be exported.

# Go to folder where daemon was created
cd /opt/soajs/node_modules/myDaemon

# Export necessary environment variables
export SOAJS_SRVIP=127.0.0.1
export SOAJS_ENV=[ENTER THE NAME OF YOUR ENVIRONMENT HERE]
export SOAJS_PROFILE=[ENTER PATH TO PROFILE HERE]
export SOAJS_DAEMON_GRP_CONF=[DAEMON GROUP CONF NAME]

# Deploy daemon
node .