做开发的都知道,
除了特定的项目,其实一般的项目看一下就知道怎么实现的,特别是应用类型的项目,比如你手机上的App等!
其实呢项目开发中的这个过程才是重要的,因为你会遇到各种问题,一些纠结点等!
所以呢用这个记录下PasteSpider的Win版本是如何实现的,以便后续可以慢慢回味,
到时候不会对自己说,我当初是咋想的,咋这么写的?
PasteSpider作为部署工具,
完整来说目前是一个开发者部署工具,
适用于linux服务器上,
也就是把你的项目部署到linux的docker或者podman上!
特色点嘛,拿几个比较突出的来讲
1.图形操作,5分钟就能上手,全部原生支持,查找相关的知识点即可,比如docker,podman,nginx,linux等
2.概念清晰,就是手动部署的程序化,就是不借用工具,你使用linux的代码,如何把你的项目部署到Linux的容器上
3.配套完整,部署服务的同时会更新对应的nginx配置,环境变量,建康检查等,还能通过报表检查是否有内存泄漏等!
4.节省资源,单个服务器的运行内存大概在200MB左右,可以带动多台服务器,具体是集群部署还是单点部署要看需求
5.运行稳定,所有的服务都是运行在宿主的docker/podman上,也就是不会因为PasteSpider停止而影响你的业务服务的正常运行
6.操作便捷,客户端支持一键升级,通过配置也可以支持git/svn的CI/CD,自动升级服务就是这么简单
7... .. .
不说多,我使用PasteSpider部署项目的次数至少大于3000次,
这个数据是有据可循的,
涉及到.netcore,php,html,vue,node等!
由于是使用.netcore写的,
作为.net嘛还是很多人部署服务在IIS上的,
所以就有这么一个需求,
升级PasteSpider让他支持IIS!
!!!也就是实现使用IIS部署项目!!!
这个呵呵,没法考虑,太不稳定了,而且麻烦!
这个的资料我看过,其实还是可以的,主要是我感觉这个命令太。。。
太那个啥呢,
主要是语法啥的和我们的习惯不一样,
IIS的配置项目非常多,
用这个要学习和测试的内容太多了!
先保留,如果100分的话,我大概会打70分吧!
官方资料在这
Microsfot.Web.Administration
这东西我看得迷糊,感觉只能操作一小部分信息,多半是不行的!
IIS 7.0 及更高版本提供了一个全面的托管代码管理应用程序编程接口 (API),它允许完全操作 XML 配置文件,并可方便地访问服务器对象。 本文档逐步讲解如何使用新的管理 API 来修改服务器配置和管理服务器对象。
IIS 包括 Microsoft.Web.Administration,这是一个新的 Web 服务器管理 API,它通过完全操作 XML 配置文件来支持编辑配置。 它还提供了用于管理服务器及其属性和状态的便利对象。 API 的配置编辑方面提供对 IIS 配置文件层次结构和特定配置文件中的读取和写入配置属性的编程访问。 此 API 的对象管理方面提供了一系列顶级管理对象,用于直接管理服务器(例如站点、应用程序池、工作进程等)。
管理类驻留在 Microsoft.Web.Administration 命名空间中。 这些类提供弱类型接口,用于访问配置节和便利对象,这些对象的属性和方法表示配置的属性(如虚拟目录的路径)或要对对象执行的操作(如回收应用程序池)。
感觉这个40分都打不上,还是详细得资料我没找全?
官方资料在这
Introduction to the Microsoft IIS Administration API
这个不错,大致的意思就是在服务器上安装一个IIS Administration,然后使用REST APIS进行操作,而且还是官方的实现方式!
There are many methods available to configure IIS including appcmd.exe, PowerShell, and .NET. These methods have their benefits, but one thing they lack is an open and standard interface. The IIS Administration API builds upon the principles of REST APIs to provide an interface that can be consumed regardless of platform. This is the ultimate way to open up IIS to any client. There are few frameworks today that don't provide HTTP support, and most frameworks provide methods to simplify communicating with REST APIs. Powerful scripts can be made from a myriad of clients such as PowerShell, cURL, and Python just by performing HTTP requests with JSON payloads.
IIS Administration is the perfect option for remote management. The API is a micro service that runs on the target machine, so by nature it is meant to serve remote requests. Opening up the port that the service listens on is the only step necessary to make remote management available for the machine. This means, web site creation, application pool monitoring, and security configuration can be handled from one client for a cluster of machines with little overhead.
The IIS Administration service is being developed to completely open up IIS. There are constantly features being worked on and added. We are able to release updates quickly because the Administration Service is a separate download from the IIS service. This also has means that customers can depend on whichever version of the API that they choose.
Security is a top priority. Our service can use any form of authentication and authorization that IIS uses. This means client certificate authentication, basic authentication, and even Windows authentication. Every call made to the API requires an access token in the request header and the service is not available from outside of the machine unless the port that it listens on is opened. The built-in security allows users to confidently install the IIS Administration API on their machines without worrying that they are compromising their system.
获取还有更多得方式,需要注意得是需求是多方面的
1.项目文件,项目文件的存放,版本更新等
2.需要和nginx等配合使用,集群部署等
3.能够读取当前服务器的可用端口等,服务器的资源信息等
4.容易上手,版本不能太旧了!
从上面的方案中,我选择的是方案四!
按照上面的方案四的资料,我下载了对应的资料,注意安装的时候需要使用管理员的身份运行!
后打开 https://localhost:55539/
如官方所示的,看到了如下界面
按照上面的提示,操作了下,结合文档,可以知道很多功能都是可以的我还尝试更新了一条数据,结果OK!
{
"id": "6zk-HWZT3-3Qt0oDFKwT7A",
"_links": {
"app_pools": {
"href": "/api/webserver/application-pools"
},
"authentication": {
"href": "/api/webserver/authentication/a0hCKQSTTPw4ylkFuJ7pnw"
},
"authorization": {
"href": "/api/webserver/authorization/nYUdHO8_fyyXexWIZuQ7SQ"
},
"central_certificates": {
"href": "/api/webserver/centralized-certificates/j0DyP_5_dTE4RrcNABB-Gw"
},
"default_document": {
"href": "/api/webserver/default-documents/qt8-H28Ap1-W2JvM5V_V2g"
},
"delegation": {
"href": "/api/webserver/feature-delegation"
},
"directory_browsing": {
"href": "/api/webserver/directory-browsing/ZtZyrJGQo8QnSuCSMcslXQ"
},
"global_modules": {
"href": "/api/webserver/global-modules"
},
"handlers": {
"href": "/api/webserver/http-handlers/fciI10qIzPnuqjOEKbWpdQ"
},
"http_redirect": {
"href": "/api/webserver/http-redirect/IGBGxCDQVswnfw1H1cbPKg"
},
"info": {
"href": "/api/webserver/info"
},
"ip_restrictions": {
"href": "/api/webserver/ip-restrictions/C-UspqWsgvhJlDRXypkniQ"
},
"logging": {
"href": "/api/webserver/logging/mOUXybh6TaSVOp-3HDFrDw"
},
"modules": {
"href": "/api/webserver/http-modules/DpGuKSCuHKOYTedpd8atVg"
},
"monitoring": {
"href": "/api/webserver/monitoring/6zk-HWZT3-3Qt0oDFKwT7A"
},
"request_filtering": {
"href": "/api/webserver/http-request-filtering/yxonRGW7qSxfQfnug9_fHA"
},
"request_monitor": {
"href": "/api/webserver/http-request-monitor/OLXhxo3m8Tkct933k4G8hw"
},
"request_tracing": {
"href": "/api/webserver/http-request-tracing/Mw6jSXdFqtebde15kmkipg"
},
"response_compression": {
"href": "/api/webserver/http-response-compression/xitGAw27j1wIdI5Dv6SycQ"
},
"response_headers": {
"href": "/api/webserver/http-response-headers/KX-H6JuQrYZPbg49WkYsNg"
},
"self": {
"href": "/api/webserver"
},
"service_controller": {
"href": "/api/webserver/service-controller"
},
"static_content": {
"href": "/api/webserver/static-content/Q_G7QgMqKTN3-o5asscs3w"
},
"transactions": {
"href": "/api/webserver/transactions"
},
"url_rewrite": {
"href": "/api/webserver/url-rewrite/um_m0JuIbXjrwvsfReft4g"
},
"websites": {
"href": "/api/webserver/websites"
},
"worker_processes": {
"href": "/api/webserver/worker-processes"
}
}
}
比如上面的pools可以查看程序池信息
{
"app_pools": [
{
"name": "DefaultAppPool",
"id": "Bhxu1CQ8So1MAi9Nr5rbug",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/Bhxu1CQ8So1MAi9Nr5rbug"
}
}
},
{
"name": "Classic .NET AppPool",
"id": "8UJBd7dn-dQbeKZN5SqPJ1x22Q390x0U32Fag4lnyg8",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/8UJBd7dn-dQbeKZN5SqPJ1x22Q390x0U32Fag4lnyg8"
}
}
},
{
"name": ".NET v2.0 Classic",
"id": "T6SzFXF2kNwoTjcMAoyBZ0SHxufn2UN4kdJtJ5dUvSc",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/T6SzFXF2kNwoTjcMAoyBZ0SHxufn2UN4kdJtJ5dUvSc"
}
}
},
{
"name": ".NET v2.0",
"id": "j4Z42gZVAcCn20d27c-tPw",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/j4Z42gZVAcCn20d27c-tPw"
}
}
},
{
"name": ".NET v4.5 Classic",
"id": "2WTQcPffIxIYKpW-q0bTqlHNt81E6jHiR2Uft4HPzuo",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/2WTQcPffIxIYKpW-q0bTqlHNt81E6jHiR2Uft4HPzuo"
}
}
},
{
"name": ".NET v4.5",
"id": "EKBemNEp7Crx2NEmVyvYjQ",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/EKBemNEp7Crx2NEmVyvYjQ"
}
}
},
{
"name": "iis_temp",
"id": "UYZcrUKt9eaMiolk-rH_GA",
"status": "started",
"_links": {
"self": {
"href": "/api/webserver/application-pools/UYZcrUKt9eaMiolk-rH_GA"
}
}
}
]
}
稍微看了下,结合当前的PasteSpider,主要的问题我觉得应该在IIS的配置太多了,比如程序池,绑定,限制,日志,身份验证,模块,等等非常多非常多的配置
还好的是,创建的时候一般是基于默认配置的
比如文档中有这么一个例子,创建一个网站的
{
"name": "Demonstration Site",
"physical_path": "C:\\inetpub\\wwwroot\\DemonstrationSite",
"bindings": [
{
"protocol": "HTTP",
"port": "8081",
"ip_address": *
}
]
}
读取网站信息的时候,信息是非常多的,也就是有缺省设置!
针对各种不同类型的数据的更新,下期将介绍我是如何解决这个问题的!
PS:一个项目包含多个服务,一个服务往往部署多个站点,一个站点又有多项信息,总不可能所有信息都存PasteSpider的数据库一份吧,所以就需要有一个
【动态表单】
也就是需要更新某一项配置的时候,直接根据iisadministration读取,读取为json数据,然后直接编辑这个json点击保存提交!