当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - Starting and stopping a node script from the web

问题描述:

I have a node script I'm working on that connects to an IRC channel for twitch.tv and responds to commands, as well as moderates chat lines that are being sent by other users connected.

Currently I open a terminal to the file location and run node app.js to start the IRC connection. But this runs on my mac and I use my PC to play games and watch the chat, so I have to have the Mac next to me to start and stop the IRC chat client app.

I want to move this to a web server where I can log in and start or stop the chat client app from the website, so I don't have to have the Mac next to me all the time.

What would be the best way to go about this?

If you want to see the script I'm working with you can find it here

https://github.com/Jordan4jc/super-fly-twitch-bot

网友答案:

You could create an HTTP server and listen on a port (if you don't mind overkill, express.js could make things easier for you). This server would contain configurations for the URL, authentication, etc. Within the callback that you provide to a URL path, you could close the IRC channels, database connections, and call process.exit(0) once you're confident that you've done everything necessary and you're sure it's what you want.

网友答案:

You can use socket.io as a way to send signals in real time to the application.

分享给朋友:
您可能感兴趣的文章:
随机阅读: