内容简介:centric scaffold will create a basic centric project with examples that you can modify to suit your needs.And your done!Folder Structure for a centric project.
Centric Server
A programmable automation server
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:
Argument | Description |
---|---|
config | configuration exported from config.js |
services | object containing all exported values from all service files |
opData | Current running task's operation-data. |
saveOpData | Method to be called to save the curremt operation data. |
taskData | Task data of the current running task. |
saveTaskData | Method to be called to save the current running task data. |
logInfo | logInfo is method to log the info entry showing information log of the operation. |
logWarning | logWarning is method to log the warnings entry showing warnings of the operation. |
logError | logError is method to log the errors entry showing errors of the operation. |
isCancelled | Method 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.
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
- Create Schdule form page will be displayed.
Add new schedule:
Field | Description |
---|---|
Name | Name of the schedule |
cronTime | Time interval to determine how often to run the task |
enabled? | Enable or disable this schedule |
data | Set the tasks operation data when started with this schedule |
- Click the Save button.
Creating a new user
Select Users menu from home page, users list page looks like
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.
- 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.
以上所述就是小编给大家介绍的《Centric, a Programmable Automation Server》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
如何不在网上虚度人生
[美] 肯尼思·戈德史密斯 / 刘畅 / 北京联合出版公司 / 2017-9 / 39.80元
我们平时上网多大程度上是浪费时间,多大程度是在学习、关心社会、激发创造力?我们真能彻底断网,逃离社交网络吗? 手机把都市人变成一群电子僵尸,是福是祸? 浏览记录就是我们将来的回忆录吗?文件归档属于一种现代民间艺术? 不自拍、P图、发朋友圈,我还是我吗? 美国知名概念艺术家戈德史密斯认为:上网绝不是浪费时间,而是一种创造性的活动。在本书中他以跨学科角度、散文式语言进行论证,涉及大众传播学、计算......一起来看看 《如何不在网上虚度人生》 这本书的介绍吧!