New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

centric

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

centric

A programmable automation server

0.9.2
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Centric Server

A programmable automation server

license npm version

Installation

Install centric

$ npm install -g centric
Option 1 - Use centic scaffold

centric scaffold will create a basic centric project with examples that you can modify to suit your needs.

  • Run the below command in the folder you want to create the project.
$ centric scaffold
  • After that, start the server using the command:
$ centric start

And your done!

Option 2 - Create the files yourself

Folder Structure for a centric project.

    .
    ├── services               # Service Files
    ├── tasks                  # Task Files
    ├── config.js              # Configuration file

Services

The services folder contains all your projects service files. A service file has the following signature.

module.exports = async function ({ config }) {
  // Service Logic goes here...
  const testLogging = function () {
    console.log('this is a test')
  }

  return { testLogging }
}

Services are useful for any logic you wish to share between tasks (like a database connection).

Creating a new task

Create a new file in the tasks folder that matches the following signature.

The name of the task in the centric web interface is equivalent to the name of the task file name.

module.exports = {
  description: 'task description', // Viewable in the web UI
  locks: null,
  defaultData: function () {
    // Return the default data for the task.
    // This will be the default "taskData" in the run method.
    return {}
  },
  run: async function ({ config, services, opData, saveOpData, taskData, saveTaskData, logInfo, logWarning, logError, isCancelled }) {
    // Run method is called when the task is executed.
    // Logic for the task goes here.
  }
}

The run method provides following listed parameters:

ArgumentDescription
configconfiguration exported from config.js
servicesobject containing all exported values from all service files
opDataCurrent running task's operation-data.
saveOpDataMethod to be called to save the curremt operation data.
taskDataTask data of the current running task.
saveTaskDataMethod to be called to save the current running task data.
logInfologInfo is method to log the info entry showing information log of the operation.
logWarninglogWarning is method to log the warnings entry showing warnings of the operation.
logErrorlogError is method to log the errors entry showing errors of the operation.
isCancelledMethod to check whether the task is active for running or has been cancelled.

The screen-shot below shows the list of tasks under the tasks folder. Tasks

Schedule a task

Go to the tasks list page and click over the task item for which need to schedule a task and follow the following steps:

  • Enable the task

  • Click the Create Schedule button

Tasks-Schedule

  • Create Schdule form page will be displayed.
Add new schedule:
FieldDescription
NameName of the schedule
cronTimeTime interval to determine how often to run the task
enabled?Enable or disable this schedule
dataSet the tasks operation data when started with this schedule
  • Click the Save button. Tasks-Schedule

Creating a new user

Select Users menu from home page, users list page looks like Users

To create new user click over "CREATE USER" button and add the detail of the user to be created.

Task History

The task processed are listed in the history menu under sidemenu list. History

  • It provides the list of task operations processed with following details.
    • Operation Number.
    • Task name of respective operation.
    • Status of the operation (i.e) Completed, Terminated, Active, Failed, Cancelled.
    • Run date of the operation.
    • Entry count: The number of logs written while the processing of the task operation.
    • Last entry message and data.

Dashboard

The dashboard page provides the list of currently running task detail.

Dashboard

FAQs

Package last updated on 09 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts