delphiki Posted October 24, 2019 Posted October 24, 2019 import sys, osimport dialogflow_v2 as dialogflowimport codecs, json from twisted.internet import defer, endpoints, protocol, reactor, taskfrom twisted.python import logfrom twisted.words.protocols import irc I am making an IRC bot for an IRC server and would like to host it 24/7it should be very low cpu intensive because it is a small server and I doubt that it will have more than a dozzen uses per hour. I don't see how to actually keep the script running though. Using the helloworld test (which does work) I assume that it only stays running while the browser window is open and restarts in a new instance every time someone opens the webpage? I also dont understand how to install dependencies? would I just package all of the required files into a folder and upload that? I understand that heliohost does not have a command interface. Is there some other way to pip install?
Krydos Posted October 24, 2019 Posted October 24, 2019 You don't install modules yourself on the shared hosting plans. If you have a vps https://www.heliohost.org/vps/ then you will have root access on the command line and you can install anything you want yourself. If you would like to continue using the shared hosting plans instead just post the following information:UsernameMain domainServerVersion of python you're usingModules you need installedBased on your username I'm thinking you're on Johnny so you can check to see if the modules are already installed with these pages Python 2.7 https://krydos2.heliohost.org/cgi-bin/modules27.py Python 3.6 https://krydos2.heliohost.org/cgi-bin/modules36.py As far as making the script run 24/7 the first thing you should know is that scripts that run 24/7 tend to cause a lot of load. HelioHost provides a way for you to monitor your load though, which if you're running high load things like this, you should probably check daily at least for the first week or so that it's running. The load graph can be found at https://johnny.heliohost.org:2083/frontend/paper_lantern/load/index.live.php If you get up to or near 100 you have a high chance of being suspended for high load. In regards to how to actually make it all work on HelioHost, I recommend taking a look at this guide I wrote https://wiki.helionet.org/Discord_Bot Just basically follow that guide, but instead of connecting to discord connect to IRC. Let us know if you have any questions.
delphiki Posted October 24, 2019 Author Posted October 24, 2019 As far as making the script run 24/7 the first thing you should know is that scripts that run 24/7 tend to cause a lot of load. HelioHost provides a way for you to monitor your load though, which if you're running high load things like this, you should probably check daily at least for the first week or so that it's running. The load graph can be found at https://johnny.heliohost.org:2083/frontend/paper_lantern/load/index.live.php If you get up to or near 100 you have a high chance of being suspended for high load.In regards to how to actually make it all work on HelioHost, I recommend taking a look at this guide I wrote https://wiki.helionet.org/Discord_Bot Just basically follow that guide, but instead of connecting to discord connect to IRC. Let us know if you have any questions. thanks it does in fact have everything I need already installed. I will actually go with a discord bot instead of IRC which I have planned to switch to for awhile. Thanks for your help and the tutorial. how strict is the ban system? I don't *think* that it should be at high load. I once had a simple IRC bot running on a RPI zero and it ran fine. I cannot find details about the CPU specs allotted to users but the usage should be rather low. Data usage should be limited to text and occasional images (not sure about if I even will have images). Is there any way to throttle load to prevent running at max for more than a certain amount of time?
Krydos Posted October 24, 2019 Posted October 24, 2019 If you get suspended it isn't the end of the world. We generally give people three chances as long as they seem to be trying to fix the issue, and we try to help them figure out why they got suspended in the first place. If your load gets too high on the graph I linked just run the stop.py script to turn off your bot.
delphiki Posted October 24, 2019 Author Posted October 24, 2019 Ok that seems more than reasonable.If you get suspended it isn't the end of the world. We generally give people three chances as long as they seem to be trying to fix the issue, and we try to help them figure out why they got suspended in the first place. If your load gets too high on the graph I linked just run the stop.py script to turn off your bot. Is there any reason why this start.py file would return an internal error (500)? #!/usr/bin/python3.6 import os, subprocess, signal print("Content-Type: text/html\n\n") counter = 0 p = subprocess.Popen(['ps', '-u', 'delphiki'], stdout=subprocess.PIPE) # must match your username --------^^^^^^^^ out, err = p.communicate() for line in out.splitlines(): if 'Jane.py'.encode('utf-8') in line: # ^^^^^^^^^^^----- this has to match the filename of your bot script counter += 1 print("Bot already running.") if counter == 0: subprocess.Popen("/home/delphiki/Jane.py") # ^^^^^^^^-- be sure to update it to your username print("Bot started!") The file does exists and is in the main directory and I have triple checked the capitalization. Permissions are 755 for all three files. I tried replacing and re-copying both of the files from the original.
Krydos Posted October 24, 2019 Posted October 24, 2019 The 500 error was because you had dos line endings. This usually happens when you use a windows computer to create your file, and then upload it. The best solution is to use an editor that understands line endings and can write linux line endings instead of dos. I changed them to linux line endings for you this time, but now your error is that you don'ty have a shebang line on your Jane.py script.
delphiki Posted October 25, 2019 Author Posted October 25, 2019 The 500 error was because you had dos line endings. This usually happens when you use a windows computer to create your file, and then upload it. The best solution is to use an editor that understands line endings and can write linux line endings instead of dos. I changed them to linux line endings for you this time, but now your error is that you don'ty have a shebang line on your Jane.py script.Thanks that worked perfectly! For anyone reading this in the future the shebang line is: #!/usr/bin/python3.6 which is necessary to tell the server which compiler to use. Also notepad++ works ok but you need to replace all /r/n with just /n.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now