zap日志写入通道被覆盖
golang离线环境依赖包问题

nats-server系统服务只能使用sc命令注册

妙音 posted @ 2021年8月19日 02:42 in golang with tags nats , 1113 阅读
 

起因描述

 
windows环境下nats-server注册成系统, 官方推荐是sc命令
 
而我觉得sc命令台太麻烦, 为什么不用github.com/kardianos/service,或者更方便的工具呢?
 

方法一:使用nssm通过界面进行配置

 
1. 下载地址
 
http://nssm.cc/download
 
2. 过程省略
 
3. 结果死活不行,由于是第三方工具,出错找不到原因,放弃
 
 

方法二:通过服务外壳作为系统服务

 
* 介绍
 
使用go生成一个demo.exe,再将demo.exe注册成系统,demo.exe读取配置文件,然后demo.exe通过exec.Command启动nats-server.exe
 
go比较好用的库可以用github.com/kardianos/service
 
 
* demo.exe启动nats-server.exe关键源码
 
p.cmd = exec.Command(fullExec, p.Args...)
p.cmd.Dir = p.Dir
p.cmd.Env = append(os.Environ(), p.Env...)
 
* demo.json配置示例
 
{
"Name": "demo",
"DisplayName": "demo",
"Description": "demo for nats-server",

"Dir": "d:\\nats-server",
"Exec": "xxxx\\nats-server.exe",
"Args": ["-c ","xxx\\nats-server.conf"],
"Env": [
],

"Stderr": "C:\\log\\nats_err.log",
"Stdout": "C:\\log\\nats_out.log"
}
 
* 结果报错
 
The service process could not connect to the service controller.
 
意思是一个服务不能连接到另一个服务,啥意思呢? 也就是通过exec.Command启动的竟然是服务,不应该是exe么.
 
* nats-server启动源码分析
 
nats-server.exe的启动入口源码
 
func Run(server *Server) error {
    //入口1:docker
if dockerized {
server.Start()
return nil
}
isInteractive, err := svc.IsAnInteractiveSession()
if err != nil {
return err
}
    //入口2: 交互模式
if isInteractive {
server.Start()
return nil
}
    //入口3: 启动服务(serviceName被写死了,只能是nats-server)
return svc.Run(serviceName, &winServiceWrapper{server})
}
 
* 错误原因总结
 
当以外壳方式启动时,走的是"入口3",也是启动服务,如果没有nats-server,它就啥事也没干,结果nats-server并没有启动
 

方法三:sc命令

 
官方推荐
 

总结

 
1、nat-server只能以sc命令注册成服务。怕麻烦可以写一个bat。
 
2、nats-server服务名只能是nats-server
 
 
Avatar_small
video alarm singapor 说:
2021年8月26日 13:55

This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work video alarm singapore

Avatar_small
AAA 说:
2021年9月03日 00:29

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! магазин интернет магазин

Avatar_small
dfg` 说:
2021年9月11日 18:41

This is my first time visit here. From the tons of comments on your articles,I guess I am not only one having all the enjoyment right here! lions breath carts

Avatar_small
dfg` 说:
2021年9月12日 22:08

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. https://barowatt.com

Avatar_small
먹튀검증 说:
2021年9月18日 14:59

If you are looking for more information about flat rate locksmith Las Vegas check that right away. 먹튀검증

Avatar_small
dfg` 说:
2021年9月21日 22:30

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. blackpods

Avatar_small
dfg` 说:
2021年9月24日 15:06

Recently, I have commenced a blog the info you give on this site has encouraged and benefited me hugely. Thanks for all of your time & work. buy organic seeds

Avatar_small
dfg` 说:
2021年9月25日 00:34

Dengue fever is another mosquito-borne deadly disease mostly finds in tropical areas. A huge number of people from India, Southeast Asia, China, the Caribbean island, and African tested Dengue Symptoms every year.

Avatar_small
Online pharmacy stor 说:
2021年9月26日 19:02

Visit Lavi Pharmacy for a Wide Range of Quality Pharmaceutical Products. Contact Lavi Pharmacy for Affordable Pharmaceutical Products Today. Online pharmacy store Port Harcourt

Avatar_small
dfg` 说:
2021年9月28日 00:37

Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet! Packing Tips: The Complete List of Dos And Don’ts For Long-Distance Moving

Avatar_small
dfg` 说:
2021年9月28日 00:57

You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!! What Is the Average Cost of Moving an Apartment?

Avatar_small
huram 说:
2021年9月28日 22:50

You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. <a href="https://www.thenewcanadians.com/?fbclid=IwAR3_6ZAviXa01yzNp94ajApHUvZANDZL3ENoZO1NTM26P0DbmDHzOqTs7eg">situs idn poker</a>

Avatar_small
merchant processing 说:
2021年10月01日 16:43

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. merchant processing iso program

Avatar_small
start your own credi 说:
2021年10月01日 18:47

Good post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Appreciate it! start your own credit card processing company

Avatar_small
YOLO 说:
2021年12月02日 20:28

สล็อต เครดิตฟรี here are both card games OnlineSlot Games

Avatar_small
Dr.Billa 说:
2021年12月11日 06:01

Thanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. I will certainly bookmark your blog and definitely will come back sometime soon. I want to encourage you to continue your great writing 온라인바카라

Avatar_small
토토사이트 说:
2021年12月21日 20:19

Good article , I am going to spend more time learning about this topic

Avatar_small
AAA 说:
2021年12月23日 16:57

Whoa that guideline is astonishing it truly helped me and my family, thanks a lot! 안전놀이터

Avatar_small
Digital_Zone 说:
2021年12月30日 19:30

I am always looking for some free kinds of stuff over the internet. There are also some companies which give free samples. But after visiting your blog, I do not visit too many blogs. Thanks. minecraft server list

Avatar_small
Digital_Zone 说:
2022年1月10日 23:11 It is a good site post without fail. Not too many people would actually, the way you just did. I am impressed that there is so much information about this subject that has been uncovered and you’ve defeated yourself this time, with so much quality. Good Works! 토토사이트
Avatar_small
Digital_Zone 说:
2022年1月10日 23:19

Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. 먹튀검증

Avatar_small
Digital_Zone 说:
2022年1月10日 23:23

Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck. 안전놀이터

Avatar_small
Digital_Zone 说:
2022年1月10日 23:28

Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks. 메이저사이트

Avatar_small
Digital_Zone 说:
2022年1月10日 23:32

Wonderful blog! Do you have any tips and hints for aspiring writers? Because I’m going to start my website soon, but I’m a little lost on everything. Many thanks! 토토사이트

Avatar_small
Digital_Zone 说:
2022年1月10日 23:36

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing 토토사이트

Avatar_small
Dr.Billa 说:
2022年1月12日 05:53

Good day! I could have sworn I’ve been to this site before but after going through some of the articles I realized it’s new to me. Anyhow, I’m certainly delighted I came across it and I’ll be bookmarking it and checking back frequently nclex study guide

Avatar_small
AAA 说:
2022年2月16日 21:59

My spouse and I absolutely love your blog and find a lot of your post’s to be exactly what I’m looking for. can you offer guest writers to write content for yourself? I wouldn’t mind publishing a post or elaborating on a number of the subjects you write related to here. Again, awesome weblog! 토토사이트

Avatar_small
Dr.Billa 说:
2022年2月18日 04:52

Online Hold'em Community in Korea 홀덤사이트

Avatar_small
Digital_Zone 说:
2022年2月21日 04:25 Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. 토토사이트
Avatar_small
Digital_Zone 说:
2022年2月21日 04:31

Well-Written article. It will be supportive to anyone who utilizes it, including me. Keep doing what you are doing – can't pause to read more posts. Thanks for the precious help. 메이저사이트

Avatar_small
Digital_Zone 说:
2022年2月21日 04:37

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. 안전놀이터

Avatar_small
Dr.Billa 说:
2022年2月23日 12:07

Bolaku Situs Bandar Bola Agen Judi Online Terpercaya , Bolaku merupakan situs bandar bola resmi yang telah diakui berbagai agen dunia asia tepatnya di Indonesia dengan menyediakan pasaran taruhan judi online hingga puluhan tipe game terlengkap. bolaku

Avatar_small
Dr.Billa 说:
2022年3月01日 23:12

The Netgear extenders can be used to increase the coverage area. Network. The Netgear extender setup is highly effective. Double their wireless network range. If you have any problems, however, problem with how to setup a netgear wifi extender, you can call on toll free and take technical assistance from experts. 192.168.1.250

Avatar_small
Dr.Billa 说:
2022年3月15日 10:29

I enjoyed reading this post such an interesting info post. Thanks for providing good info on the topic of สมัครpg slot

Avatar_small
Dr.Billa 说:
2022年3月18日 07:43

I am hoping that you will continue writing this kind of blog. Thanks for sharing this information. joker สล็อต888

Avatar_small
Dr.Billa 说:
2022年3月22日 01:55

You make so many great points here that I read your article a couple of times. This is great content for your readers. ufabet เข้าสู่ระบบ

Avatar_small
Digital_Zone 说:
2022年4月06日 22:31

Best work you have done, this online website is cool with great facts and looks. I have stopped at this blog after viewing the excellent content. I will be back for more qualitative work. 먹튀폴리스

Avatar_small
Digital_Zone 说:
2022年4月06日 22:38

Interesting and amazing how your post is! It Is Useful and helpful for me That I like it very much, and I am looking forward to Hearing from your next.. 토토사이트

Avatar_small
Digital_Zone 说:
2022年4月06日 22:49

I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before. 릴게임

Avatar_small
cyber 说:
2022年4月14日 06:35

Thanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. I will certainly bookmark your blog and definitely will come back sometime soon. I want to encourage you to continue your great writing 작업대출사이트

Avatar_small
cyber 说:
2022年5月04日 06:01

สล็อต สล็อตออนไลน์ เกมสล็อต เว็บสล็อต สล็อต เล่น ฟรี สล็อต 888 สล็อตออนไลน์ มือ ถือ เกมสล็อต ทดลองเล่นสล็อต สล็อต

Avatar_small
먹튀검증 说:
2022年5月04日 13:07

grew up with a passion for sports and numbers. Steve had great achievement as a student, in the aspects of mathematics and statistics. He'd ultimately generate his PhD

Avatar_small
cyber 说:
2022年5月10日 19:45

This was really very informative site for me I really liked it I felt very happy while reading this site 토토사이트 순위

Avatar_small
cyber 说:
2022年6月03日 04:59

This Post is providing valuable and unique information✅ I know that you take a time and effort to make a awesome article 꽁머니

Avatar_small
Dr.Billa 说:
2022年6月10日 05:19

mtpolice.kr provides sports betting information, sports analysis, and sports tips as a sports community.검증사이트

Avatar_small
cyber 说:
2022年6月15日 20:37

Superior post keeps up with this exceptional work✅. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! เน็ตทรู

 

 

 

 

Thanks for this great post, I find it very interesting and very well thought out and put together. I look forward to reading your work in the future. เน็ตทรูรายเดือน

 

 

 

 

Thanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. I will certainly bookmark your blog and definitely will come back sometime soon. I want to encourage you to continue your great writing สมัครเน็ตทรูรายเดือน

 

 

 

 

 

Everything is very open with a very clear description of the challenges. It was definitely informative. Your website is very helpful. Thanks for sharing On that website page, you'll see your description, why not read through this เน็ตทรูรายสัปดาห์

 

 

 

 

 

Great work✅ This is the type of information that should be shared around the web. I also have some information related to on my website เน็ตทรูรายวัน

 

 

 

 

 

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! เน็ตทรูรายวัน ไม่ลดสปีด

 

 

 

 

 

Fabulous post✅ you have denoted out some fantastic points regarding สมัครเน็ตทรู

 

 

 

 

What a fantabulous post ✅. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much เน็ตทรูรายเดือน

 

 

 

 

 

I appreciate your efforts in preparing this post. I really like your blog articles on ไม่ลดสปีด สมัครเน็ตทรูรายเดือน

 

 

 

 

 

 

​Everything has its own value, but this is really precious information✅ shared by Author of เน็ตทรูรายสัปดาห์

Avatar_small
cyber 说:
2022年6月16日 10:22

There are baby fleece blankets that have hoods and pockets. custom fleece blankets

 

 

 

 

 

 

 

 

 

We publish daily results of the biggest lottery in India called the Lottery Sambad. It is also called Dear Lottery. Dear Lottery

Avatar_small
Dr.Billa 说:
2022年6月17日 09:54

You amazingly have terrific article content. Cheers for sharing your blog site. Thank you for sharing this เน็ตทรูรายวัน ไม่ลดสปีด

 

 

 

Wow, What an Outstanding post✅. I found this too much informatics. It is what I was seeking for เน็ตทรูรายวัน ไม่ลดสปีด

 

 

 

 

 

Excellent article. I want to thank you for this informative read; I really appreciate sharing this great post. Keep up your work! เน็ตทรูรายเดือน

 

 

 

 

 

It’s really a fantastic website ✅ thanks for sharing. There's no doubt I would fully rate it after i read what the idea about this article is เน็ตทรูรายสัปดาห์

 

 

 

 

 

 

Hi there! You make so many good points here that I read your article a couple of times. This is really nice content for your readers. เน็ตทรูรายอาทิตย์ ไม่ลดสปีด

 

 

 

 

 

I found useful information on this topic✅. Thank you posting relative information and its currently becoming easier to complete this project โปรเน็ต AIS

 

 

 

 

 

 

Good day! I could have sworn I’ve been to this site before but after going through some of the articles I realized it’s new to me. Anyhow, I’m certainly delighted I came across it and I’ll be bookmarking it and checking back frequently เน็ต ais รายสัปดาห์

 

 

 

 

 

 

 

 

Nice post ✅. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part เน็ต ais รายเดือน

 

 

 

 

 

 

 

 

 

 

Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. 

 

 

 

 

 

 

 

 

 

Thanks for such a valuable help again aw8

 

 

 

 

 

 

 

 

 

I prefer merely excellent resources and you can see these in เน็ตทรูรายวัน

Avatar_small
cyber 说:
2022年6月18日 21:46

Definitely a fantastic publish✅. The information you have provided is actually very worthwhile. aw8

 

 

 

 

You make so many great points here that I read your article a couple of times. This is great content for your readers. aw8

 

 

 

 

 

This is a great article and great read for me✅. It's my first visit to your blog ut9winth

 

 

 

 

 

 

I am hoping that you will continue writing this kind of blog. Thanks for sharing this information. ut9winth

 

 

 

 

 

 

 

This Post is providing valuable and unique information✅ I know that you take a time and effort to make a awesome article ut9winth

 

 

 

 

 

 

 

I enjoyed reading this post such an interesting info post. Thanks for providing good info on the topic of happyluke

 

 

 

 

 

 

 

Everything has its own value, but this is really precious information✅ shared by Author of happyluke

 

 

 

 

 

 

 

I appreciate your efforts in preparing this post. I really like your blog articles on happyluke

 

 

 

 

 

 

What a fantabulous post ✅. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much jbo

 

 

 

 

 

 

 

Fabulous post✅ you have denoted out some fantastic points regarding jbo

Avatar_small
cyber 说:
2022年6月26日 22:09

Online poker information community in Korea 홀덤

Avatar_small
Dr.Billa 说:
2022年6月27日 05:42

Where ideas and insights are shared Trending Chefs

Avatar_small
cyber 说:
2022年6月30日 21:52

This specific seems to be definitely excellent. University of Chester

Avatar_small
dark web links 说:
2022年7月03日 19:52

When you have done all of this you should still be wondering what to do if your son is on the dark web links.

Avatar_small
dark web links 说:
2022年7月03日 20:14

Changing your passwords can be one of the best things that you can do because it will make it harder for the hacker to access any information that is on your computer.

Avatar_small
dark web 说:
2022年7月03日 20:30

Therefore, you should change your password on a regular basis and use a new email address that is not the same as the one that you use for work.

Avatar_small
dark web sites 说:
2022年7月03日 20:44

Also, you should make sure that you always keep your antivirus running in order to protect yourself from any viruses or worms that are sent by hackers online.

Avatar_small
deep web 说:
2022年7月03日 20:56

Anyone who has ever wanted to look up information on a product, a person, or something in order to make an informed decision about it knows how difficult it can be when you want to get information that is quick and easy.

Avatar_small
cyber 说:
2022年7月07日 23:50

It’s really a fantastic website ✅ thanks for sharing. There's no doubt I would fully rate it after i read what the idea about this article is 바둑이게임

Avatar_small
바카라사이트 说:
2022年7月30日 11:35

Cheers for this excellent. I was wondering whether you were planning of publishing similar posts to this. .Keep up the excellent articles! 바카라사이트 카지노사이트

Avatar_small
aqsa 说:
2022年8月03日 03:36

Wow that was unusual. I just wrote an incredibly long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say wonderful blog! https://totoworld24.com

Avatar_small
dark web/deep web/d 说:
2022年8月06日 22:59

It's not uncommon to see links that direct you to music, movies, adult sites, or any other form of content that you can imagine. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:34

Instead of using deceptive tactics, these people are content to allow other webmasters to use their resources without charging them a fee. Of course, there is always the risk of getting found out (which is why you should make sure you use legitimate links). deep web

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:52

While this usually takes less time than writing an email to the site or having a chat with someone at the site, it is a step you should not neglect taking.  dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:11

Links on the dark Web should be carefully scrutinized because many of them are fake or infected with malware. Some Web sites contain hundreds of link partners that funnel your information to countless other Web sites.  dark web sites

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:29

Most people have become accustomed to clicking on links that appear to be legitimate and then being redirected to a site that is phony. If you get a warning message saying that your download is fraudulent, then don't proceed and contact the site operator. dark web

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:58

Affiliate marketing on ClickBank is simple. First, register yourself with them. This can usually be done in a matter of minutes.  work from home jobs

Avatar_small
dark web/deep web/d 说:
2022年8月07日 01:20

If you are still wondering how to start affiliate marketing with ClickBank, this process will help you. Once you have found the products you want to promote, you need to sign up as an affiliate with the affiliate program. affiliate marketing success

Avatar_small
aqsa 说:
2022年8月09日 07:00

I enjoyed reading this post such an interesting info post. Thanks for providing good info on the topic of 메이저카지노

Avatar_small
aqsa 说:
2022年8月09日 07:50

Royalgreen by Allgreen Properties Limited. Hotline 61004343. Get Discounts, Direct Developer Price, Floor Plan, Price List, Brochure & More. royalgreen condo

Avatar_small
cyber 说:
2022年8月14日 04:51

This is a great article and great read for me✅. It's my first visit to your blog 파라오카지노

Avatar_small
aqsa 说:
2022年8月19日 01:38

I was seeking this particular information for a very long time. ✅ I also have some information related to this Topic on my website Selling Credit Card Processing

Avatar_small
aqsa 说:
2022年8月19日 04:18

I am hoping that you will continue writing this kind of blog. Thanks for sharing this information. PYRODEX SELECT POWDER

Avatar_small
aqsa 说:
2022年8月21日 04:46

Nice and interesting post, I was looking for this kind of information and enjoyed reading this buy viagra online

Avatar_small
cyber 说:
2022年8月22日 21:02

Startupo.fr est un site web qui propose des formations en ligne pour les entrepreneurs. Les cours sont divisés en trois niveaux : débutant, intermédiaire et expert. Chaque niveau contient plusieurs modules, et chaque module contient plusieurs leçons. Le niveau débutant est destiné aux personnes qui découvrent le monde de l'entrepreneuriat et aborde des sujets tels que le business plan et le marketing. Le niveau intermédiaire s'adresse à ceux qui ont une certaine expérience dans ce domaine et couvre des sujets tels que la planification financière et la gestion d'équipe. Le niveau expert est conçu pour ceux qui sont déjà des entrepreneurs expérimentés, et il couvre des sujets tels que le pitching aux investisseurs et la mise à l'échelle d'une entreprise. Startupo.fr propose également un cours sur Enlign, qui est un outil utilisé par les entrepreneurs pour gérer leur entreprise. Enlign est un logiciel qui aide les utilisateurs à suivre leurs progrès, à fixer des objectifs et à gérer leur temps. Il est disponible en version française et anglaise. Startupo.fr propose un essai gratuit d'Enlign afin que les utilisateurs puissent l'essayer avant de décider de l'acheter. Startupo.fr

Avatar_small
aqsa 说:
2022年8月27日 02:49

Hyll On Holland is located at 91-95 Holland Road, District 10 of Singapore. The condo is freehold tenure, providing 319 units developed by Far East Consortium International Limited (FEC). hyll on holland condo

 

 

 

 

 

 

 

 

 

​Juniper Hill by Allgreen Properties. Hotline 61004343. Get Discounts, Direct Developer Price, Floor Plan, Price List, Brochure & More. juniper hill condo

Avatar_small
meidir 说:
2022年10月04日 05:20

I as well as my buddies were digesting the nice items located on your site and so all of the sudden got a terrible suspicion I never expressed respect to the blog owner for those techniques. All of the ladies had been certainly passionate to study all of them and have pretty much been taking pleasure in these things. Thank you for genuinely really accommodating as well as for finding certain exceptional resources millions of individuals are really needing to know about. My very own honest apologies for not saying thanks to earlier. iPhone 14


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter