Application Manager 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Application Manager 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Application Manager 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
开发语言 C/C++
操作系统 跨平台
软件类型 开源软件
开源组织
地区 国产
投 递 者 我本善良-
适用人群 未知
收录时间 2018-10-11

软件简介

Application Manager,程序管理器,可以用来替代supervisor和cron-tab,用来管理计算机上部署的各种类型的程序,支持定视任务,长任务,提供命令行和REST接口。

Setup build environment on Ubuntu

apt-get install g++ git make zlib1g-dev libssl-dev cmake
apt-get install libboost-all-dev libcpprest-dev libjsoncpp-dev libace-dev libgoogle-glog-dev libcctz-dev

 

REST APIs

# Application Manager
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
![coverage](https://img.shields.io/badge/coverage-90%25-yellowgreen.svg?maxAge=2592000)
![version](https://img.shields.io/badge/version-1.1.0-blue.svg?maxAge=2592000)

## Introduction
Application Manager is a daemon application to manage different types of sub-applications(process), each application can be a specific jobs, the app-manager will make sure all defined applications running on-time with defined behavior. provide REST APIs for integrate with outside app, provide command-line to start/stop and register new app easily. Also can be a JWT server.

The internal timer is multi-threaded with high-precision that can be used to replace Linux cron-tab and supervisor.

<div align=center><img src="https://github.com/laoshanxi/app-manager/raw/master/doc/diagram.png" width=654 height=385 align=center /></div>


Supported applications  | Behavior
---|---
Long running application | Monitor app running all time and restart when exited immediately
Short runing application | Periodic startup app
Periodic long running application |Long running applicatin but will be restart periodic
Extra Features | Application can define avialable time range in a day <br> Application can define envionment variables <br> Application can define resource (memory & CPU) limitation (cgroup on Linux) <br> SSL support <br> Collect host/app resource usage <br> Remote run shell commands <br> JWT authentication


## Setup build environment on CentOS/Ubuntu/Debian
```
git clone https://github.com/laoshanxi/app-manager.git
sudo sh app-manager/autogen.sh
```
## Build
```
cd app-manager
make
```

## REST APIs

Method | URI | Desc
---|---|---
GET | /app/$app-name | Get an application infomation
GET | /app/$app-name/testrun?timeout=5 | Test run an application
GET | /app/$app-name/testrun/output?process_uuid=uuidabc | Get the stdout and stderr for the test run
GET | /app-manager/applications | Get all application infomation
GET | /app-manager/resources | Get host resource usage
GET | /app-manager/config | Get all the configuration
PUT | /app/$app-name | Register a new application
POST| /app/$app-name?action=start | Start an application
POST| /app/$app-name?action=stop | Stop an application
POST| /authenticate | JWT authenticate
DELETE| /app/$app-name | Unregister an application

## How to install
**CentOS**:
```
wget https://github.com/laoshanxi/app-manager/releases/download/v1.0/appmanager-1.0-1.x86_64.rpm
sudo yum install ./appmanager-1.0-1.x86_64.rpm -y
```
If you directly run command line from installation console, there will have issue on dependency libraries, you need source /opt/appmanager/script/app.bashrc to get the environment. for the new console will be OK, the source operation was automaticlly add to /etc/bashrc
```
$ appc view
appc: error while loading shared libraries: libcpprest.so.2.10: cannot open shared object file: No such file or directory

$ source /opt/appmanager/script/app.bashrc 

$ appc view
id user  active pid   return memory name        command_line
1  root  start  4485  0      0.3M   period      /bin/sleep 20
2  root  start  2048  0      1.9M   ping        ping www.baidu.com
```
**Ubuntu**:
```
$ apt-get install appmanager_1.0_amd64.deb
```

## Show all sub command

```
$ appc
Commands:
  view        List application[s]
  config      Display configurations
  resource    Display host resource usage
  start       Start a application
  stop        Stop a application
  restart     Restart a application
  reg         Add a new application
  unreg       Remove an application
  test        Test run an application and get output
  sh          Use shell run a command and get output

Run 'appc COMMAND --help' for more information on a command.

Usage:  appc [COMMAND] [ARG...] [flags]
```


## List application[s]

```
$ appc view
id user  active pid   return memory name        command_line
1  root  start  2350  0      0.3M   period      /bin/sleep 20
2  root  start  1860  0      1.9M   ping        ping www.baidu.com
$ appc view -n ping
id user  active pid   return memory name        command_line
1  root  start  1860  0      1.9M   ping        ping www.baidu.com
```

## Display host resource usage

```
$ appc resource
{
   "cpu_cores" : 4,
   "cpu_processors" : 4,
   "cpu_sockets" : 1,
   "host_name" : "myubuntu",
   "mem_freeSwap_bytes" : 1023406080,
   "mem_free_bytes" : 3755048960,
   "mem_totalSwap_bytes" : 1023406080,
   "mem_total_bytes" : 5189935104,
   "net_ip" : [
      {
         "docker0" : "172.17.0.1"
      },
      {
         "enp0s3" : "10.0.2.15"
      }
   ]
}
```

## Display configurations

```
$ appc config
{
        "Applications" : 
        [
                {
                        "active" : 1,
                        "command_line" : "/bin/sleep 20",
                        "daily_limitation" : 
                        {
                                "daily_end" : "23:00:00",
                                "daily_start" : "09:00:00"
                        },
                        "env" : 
                        {
                                "TEST_ENV1" : "value",
                                "TEST_ENV2" : "value"
                        },
                        "keep_running" : true,
                        "name" : "period",
                        "posix_timezone" : "CST+8:00:00",
                        "resource_limit" : 
                        {
                                "cpu_shares" : 100,
                                "memory_mb" : 200,
                                "memory_virt_mb" : 300
                        },
                        "run_as" : "root",
                        "run_once" : false,
                        "start_interval_seconds" : 30,
                        "start_interval_timeout" : 0,
                        "start_time" : "2018-01-01 16:00:00",
                        "working_dir" : "/opt"
                },
                {
                        "active" : 1,
                        "command_line" : "ping www.baidu.com",
                        "name" : "ping",
                        "run_as" : "root",
                        "run_once" : false,
                        "working_dir" : "/tmp"
                }
        ],
        "Description" : "myhost",
        "LogLevel" : "DEBUG",
        "RestListenPort" : 6060,
        "SSLCertificateFile" : "server.crt",
        "SSLCertificateKeyFile" : "server.key",
        "SSLEnabled" : true,
        "ScheduleIntervalSeconds" : 2
}

```

## Register a new application

```
$ appc reg
Register a new application:
  -n [ --name ] arg              application name
  -u [ --user ] arg (=root)      application process running user name
  -c [ --cmd ] arg               full command line with arguments
  -w [ --workdir ] arg (=/tmp)   working directory
  -a [ --active ] arg (=1)       application active status (start is true, stop
                                 is false)
  -t [ --start_time ] arg        start date time for short running app (e.g., 
                                 '2018-01-01 09:00:00')
  -s [ --daily_start ] arg       daily start time (e.g., '09:00:00')
  -d [ --daily_end ] arg         daily end time (e.g., '20:00:00')
  -m [ --memory ] arg            memory limit in MByte
  -v [ --virtual_memory ] arg    virtual memory limit in MByte
  -p [ --cpu_shares ] arg        CPU shares (relative weight)
  -d [ --daily_end ] arg         daily end time (e.g., '20:00:00')
  -e [ --env ] arg               environment variables (e.g., -e env1=value1 -e
                                 env2=value2)
  -i [ --interval ] arg          start interval seconds for short running app
  -x [ --extra_time ] arg        extra timeout for short running app,the value 
                                 must less than interval  (default 0)
  -z [ --timezone ] arg          posix timezone for the application, reflect 
                                 [start_time|daily_start|daily_end] (e.g., 
                                 'WST+08:00' is Australia Standard Time)
  -k [ --keep_running ] arg (=0) monitor and keep running for short running app
                                 in start interval
  -f [ --force ]                 force without confirm.
  -h [ --help ]                  help message

  
$ appc reg -n ping -u kfc -c 'ping www.google.com' -w /opt
Application already exist, are you sure you want to update the application (y/n)?
y
{
   "active" : 1,
   "command_line" : "ping www.google.com",
   "name" : "ping",
   "pid" : -1,
   "return" : 0,
   "run_as" : "kfc",
   "working_dir" : "/opt"
}
```


## Remove an application
```
appc unreg -n ping
Are you sure you want to remove the application (y/n)?
y
Success
```

## Start an application
```
$ appc start -n ping
```

## Stop an application
```
$ appc stop -n ping
```

## Test run an application and get stdout
``` sh
$ appc test -n ping -t 5
PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244: icmp_seq=1 ttl=55 time=20.0 ms
64 bytes from 220.181.112.244: icmp_seq=2 ttl=55 time=20.1 ms
64 bytes from 220.181.112.244: icmp_seq=3 ttl=55 time=20.1 ms
64 bytes from 220.181.112.244: icmp_seq=4 ttl=55 time=20.1 ms
64 bytes from 220.181.112.244: icmp_seq=5 ttl=55 time=20.1 ms
```

## Run a shell command and get stdout
``` sh
$ appc sh -e LD_LIBRARY_PATH=/opt/appmanager/lib64 -c "appc view" 
{
        "active" : 0,
        "command_line" : "/bin/sh -c 'export LD_LIBRARY_PATH=/opt/appmanager/lib64;appc view'",
        "env" : 
        {
                "LD_LIBRARY_PATH" : "/opt/appmanager/lib64"
        },
        "memory" : 0,
        "name" : "58de823f-cecf-4b67-b362-d08db46167f6",
        "pid" : -1,
        "return" : 0,
        "run_as" : "root",
        "run_once" : true,
        "working_dir" : "/tmp"
}

id user  active pid   return memory name        command_line
1  root  start  2605  0      0.3M   period      /bin/sleep 20
2  root  start  1860  0      1.9M   ping        ping www.baidu.com
3  root  stop   0     0      0      58de823f-c* /bin/sh -c 'export LD_LIBRARY_PATH=/opt/appmanager/lib64;appc view'
Process already finished or killed by timeout event
application <58de823f-cecf-4b67-b362-d08db46167f6> removed.
```

![example](https://github.com/laoshanxi/app-manager/blob/master/doc/example.gif?raw=true) 

## Remote run a shell command
![appc_sh](https://github.com/laoshanxi/app-manager/blob/master/doc/appc_sh.gif?raw=true) 

## Usage scenarios
1. Integrate with package installation script and register startup command to app manager automaticlly
2. Install on remote host to execute command remotly and get output (can build-up web ssh)
3. Get resource usage (cpu/memory) for each application and host resource status

## 3rd party deependencies
- [C++11](http://www.cplusplus.com/articles/cpp11)
- [ACE](https://github.com/DOCGroup/ACE_TAO)
- [Microsoft cpprestsdk](https://github.com/Microsoft/cpprestsdk)
- [boost](https://github.com/boostorg/boost)
- [jsoncpp](https://github.com/open-source-parsers/jsoncpp)
- [log4cpp](http://log4cpp.sourceforge.net)
- [jwt_cpp](https://thalhammer.it/projects/jwt_cpp)

## Design
### Thread model
<div align=center><img src="https://github.com/laoshanxi/app-manager/blob/master/doc/threadmodel.jpg?raw=true" align=center /></div>

URI
GET /app/$app-name
GET /app-manager/applications
GET /app-manager/config
PUT /app/$app-name
POST /app/$app-name?action=start
POST /app/$app-name?action=stop
DELETE /app/$app-name

Show all sub command

$ appc
Commands:
  view        List application[s]
  config      Display configurations
  start       Start a application
  stop        Stop a application
  reg         Add a new application
  unreg       Remove an application

Run 'appc COMMAND --help' for more information on a command.

Usage:  appc [COMMAND] [ARG...] [flags]
展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论 (3)

加载中
main.o:在函数‘monitorAllApps(boost::system::error_code const&)’中: /usr/include/boost/serialization/singleton.hpp:103:对‘boost::serialization::singleton_module::get_lock()’未定义的引用 main.o:在函数‘boost::serialization::singleton::get_mutable_instance()’中:
2018/10/15 00:15
回复
举报
我本善良-软件作者
编译不会有问题的啊,要先执行autogen.sh然后再编译
2019/06/28 16:46
回复
举报
我本善良-软件作者
打分: 力荐
C++力作
2018/10/12 11:12
回复
举报
更多评论
暂无内容
发表了博客
2011/05/16 11:18

猎头职位: Web Application Project Manager(上海,两年工作经验...

JOB DESCRIPTION 职位描述 Company Name公司名称: Saint-Gobain (China) Investment Co., Ltd. Job Info: 职位信息 Title职位:Web Application Project Manager Dept/Div 所属部门:Saint-Gobain AsiaPacific General Delegation – Technology Services Reports to 直接主管:Web & Collaboration Solutions Manager Location 所在地:Shanghai Job Purpose: 职位目的 As part of Saint-Gobain Technology Services AsiaPaci...

0
1
发表了博客
2018/03/16 14:49

Tomcat 访问 Manager App,Host Manager

   1、启动tomcat,在浏览器输入:http://localhost:8080/        2、配置tomcat-users.xml 文件     在主目录的cong文件夹下找到tomcat-users.xml 文件中配置用户角色:     针对第三个按钮“Host Manager”,配置角色时一定把角色配全。修改tomcat-users.xml 文件,加入如下代码:      <role rolename="admin-gui"/> <role rolename="manager-gui"/> <user username="tomcat" password="tomcat" ro...

0
0
发表了博客
2015/09/20 10:56

SDK Manager

The Android SDK Manager separates the SDK tools, platforms, and other components into packages for easy access and management. You can also customize which sites the SDK Manager checks for new or updated SDK packages and add-on tools. For example, you can configure the SDK Manager to automatically check for updates and notify you when an installed SDK Tools package is updated. When you receive ...

0
0
发表于开发技能专区
2014/05/01 17:50

Tomcat Manager

一、概述 可以通过访问Tomcat的Manager服务对服务器进行管理。 二、Tomcat Manager配置 (一)用户配置 #cd /opt/tomcat/conf #vim tomcat-users.xml 在该文件中添加以下内容: <tomcat-users>     <role name="manager-gui"/>     <user name="admin" password="123" roles="manager-gui"/> </tomcat-users> manager-gui是默认的管理员角色。在文件中有注释说明,不同版本可能不一样!! 三、Tomcat Manager 功能 ...

0
5
发表了博客
2019/08/12 12:51

Replication-Manager

MYSQL5.7下搭建Replication-Manager 环境说明 在主机1,主机2,主机3上安装MySQL服务端和客户端。 主机1 主机2 主机3 操作系统 CentOS7.4 CentOS7.4 CentOS7.4 主机名 mydb1 mydb2 mydb3 IP 192.168.1.101 192.168.1.102 192.168.1.103 角色 主 从 从 ProxySQL Replication-Manager 数据库软件版本 mysql5.7.22 mysql5.7.22 mysql5.7.22 MySQL配置文件 /app/mysqldata/3306/ my.cnf /app/mysqldata/3306/ my.cnf /app/mysqldata...

0
0
发表了博客
2018/08/15 14:01

Kafka Manager

Kafka Manager 这里记录下安装过程,以及当时遇到的一些问题。 依赖项 kafka manager依赖两个组件: java8 最新的kafka manager依赖java8,低版本的我没有尝试过。这里不对配置java8做说明 sbt sbt是一个scala项目的构建工具,我们通过下载kafka manager源码方式的话,就需要去构建工程。 安装sbt的过程如下: 下载sbt包 sbt下载,可以通过这个链接去下载自己想要的版本,我这里选择的是一个相对低的版本:0.13.17。 解压包 配置...

0
0
发表了博客
2013/08/29 22:38

Manager_Quickstart

环境准备 1. otter manager依赖于mysql进行配置信息的存储,所以需要预先安装mysql,并初始化otter manager的系统表结构 a. 安装mysql,这里不展开,网上一搜一大把 b. 初始化otter manager系统表: 下载: wget https://raw.github.com/alibaba/otter/master/manager/deployer/src/main/resources/sql/otter-manager-schema.sql 载入: source otter-manager-schema.sql 2. 整个otter架构依赖了zookeeper进行多节点调度,所以需...

0
0
发表了博客
2018/02/26 23:14

Block Manager

在Spark中,将数据抽象为Block(不论是shuffle数据,还是节点本身存储的数据),而每个driver/executor中的block都是由`BlockManager`这个类来负责管理的。对于block实际的读取,`BlockManager`根据block存储位置的不同是交由`ShuffleManager`, `MemoryStore`或`DiskStore`来实际处理的。`BlockManager`管理的block可能是shuffle后的文件,也可能是缓存的数据。对于shuffle文件中的block是通过`ShuffleManager`来管理的。对于节...

0
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
暂无内容
3 评论
1 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部