Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make service working on Windows & Switch winpty to conpty on Windows 10 #20

Merged
merged 1 commit into from
May 21, 2024

Conversation

uubulb
Copy link
Contributor

@uubulb uubulb commented May 19, 2024

Windows的服务需要主命令返回一个“成功”状态才能正确启用,于是把原来service.go里的服务创建部分移到main.go里了,并创建了新函数runService用来daemonize agent
诡异的是改完之后macos又不能通过launchctl启动了(直接运行没事),只能暂时搞个判断条件让macos运行原来的方法
另外加了一个build tag windows10 用于使用conpty代替原先的winpty,conpty是微软官方pty实现(需要version 1809以上),全架构通用,不需要额外依赖。这样agent也可以在win10/11 arm64上跑了。

@naiba
Copy link
Member

naiba commented May 19, 2024

windows10 自动更新会影响吧,会下载 windows10 专用 binary 吗?

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

windows10 自动更新会影响吧,会下载 windows10 专用 binary 吗?

conpty是内置的,不用下载任何东西

@naiba
Copy link
Member

naiba commented May 19, 2024

windows10 自动更新会影响吧,会下载 windows10 专用 binary 吗?

conpty是内置的,不用下载任何东西

win10 agent 自动更新

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

windows10 自动更新会影响吧,会下载 windows10 专用 binary 吗?

conpty是内置的,不用下载任何东西

win10 agent 自动更新

抱歉理解错了,这个还需要改一下

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

windows10 自动更新会影响吧,会下载 windows10 专用 binary 吗?

conpty是内置的,不用下载任何东西

win10 agent 自动更新

要不单开一个仓库放win10的binary吧,这个方式比较简单。

@naiba
Copy link
Member

naiba commented May 19, 2024 via email

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

不要这么做

On Sun, May 19, 2024 at 22:09 UUBulb @.> wrote: windows10 自动更新会影响吧,会下载 windows10 专用 binary 吗? conpty是内置的,不用下载任何东西 win10 agent 自动更新 要不单开一个仓库放win10的binary吧,这个方式比较简单。 — Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG7DUMPL4XLHCJQT4FFUGQ3ZDCXAZAVCNFSM6AAAAABH6JS4GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGI2TCNBZGA . You are receiving this because you commented.Message ID: @.>

那我改一下selfupdate,加一个win10的参数

@naiba
Copy link
Member

naiba commented May 19, 2024

既然能在 selfupdate 判断win10,也可以在 pty_windows 那里判断下,不用搞这么麻烦还要单独一个 binary

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

既然能在 selfupdate 判断win10,也可以在 pty_windows 那里判断下,不用搞这么麻烦还要单独一个 binary

抱歉没看到,等会改

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

既然能在 selfupdate 判断win10,也可以在 pty_windows 那里判断下,不用搞这么麻烦还要单独一个 binary

好吧,我试了不行,不搞单独binary的话判断条件会比较麻烦,而且在编译windows arm64的时候go-winpty会弹错误(因为他没作arm64兼容):
../../go/pkg/mod/github.com/iamacarpet/[email protected]/winpty.go:72:19: undefined: createAgentCfg
../../go/pkg/mod/github.com/iamacarpet/[email protected]/winpty.go:112:19: undefined: createSpawnCfg

@naiba
Copy link
Member

naiba commented May 19, 2024 via email

@uubulb
Copy link
Contributor Author

uubulb commented May 19, 2024

可以加个arm64条件编译,里面不支持winpty

On Sun, May 19, 2024 at 23:42 UUBulb @.> wrote: 既然能在 selfupdate 判断win10,也可以在 pty_windows 那里判断下,不用搞这么麻烦还要单独一个 binary 好吧,我试了不行,不搞单独binary的话判断条件会比较麻烦,而且在编译windows arm64的时候go-winpty 会弹错误(因为他没作arm64兼容): ..@./winpty.go:72:19: undefined: createAgentCfg ..@./winpty.go:112:19: undefined: createSpawnCfg — Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG7DUMKA7VWVZUT4HYH3QNDZDDB5TAVCNFSM6AAAAABH6JS4GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGI3TSNZYGI . You are receiving this because you commented.Message ID: @.>

可以了,win10 x86和win11 arm64都测试可用了。2012R2也测试可用

@uubulb uubulb force-pushed the winpty branch 2 times, most recently from a4439c4 to 54a35c7 Compare May 20, 2024 06:46
* Remove the remnants of Daocloud

* Make service working on Windows

* Fix goreleaser

* Change to a different detect method

* Simplify

* Fix version detection

* fmt

* fmt #2
@naiba
Copy link
Member

naiba commented May 20, 2024

Linux上测试过了吗

@uubulb
Copy link
Contributor Author

uubulb commented May 20, 2024

Linux上测试过了吗

pty Linux不影响吧,我没动那一块的代码
服务的话,主流的openrc和systemd都是可以用的,原始的sysvinit应该也可以。至于其它冷门init,这个得service项目里做支持了。

@naiba naiba merged commit f882ca3 into nezhahq:main May 21, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants