Jump to content

gleason

Members
  • Posts

    33
  • Joined

  • Last visited

Posts posted by gleason

  1. So this will probably end up being the same as when I donated to transfer to Tommy, evidently my program doesn't provide enough tx info. So the owner of the wallet will need to check. And I'll be doing a year worth so shouldn't be too annoying for you fellows. is 12 months the 10% discount like the 6 months  being $43.20 or is that open to discussion?

    Also, will I be able to keep my hosting on Tommy?

  2. you use a python script to start and stop the bot

    start.py in public_html/cgi-bin:

    #!/usr/bin/python3.7

    import os, subprocess, signal

    print("Content-Type: text/html\n\n")

    counter = 0
    p = subprocess.Popen(['ps''-u''mule'], stdout=subprocess.PIPE)
    # must match your username --------^^^^^^^^

    out, err = p.communicate()
    for line in out.splitlines():
      if 'node'.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("/usr/bin/node /home/mule/node/index.js"shell=True)
    #                         ^^^^^^^^-- be sure to update it to your username

      print("Bot started!")

    and stop.py in same location:

    #!/usr/bin/python3.7

    import ossubprocesssignal

    print("Content-Type: text/html\n\n")

    counter = 0
    p = subprocess.Popen(['ps''-u''mule'], stdout=subprocess.PIPE)
    # must match your username --------^^^^^^^^

    outerr = p.communicate()
    for line in out.splitlines():
      if 'node'.encode('utf-8'in line:
    #     ^^^^^^^--- this has to match the filename of your loop

        counter += 1
        pid = int(line.split(None1)[0])
        print("Stopping bot.")
        os.kill(pidsignal.SIGTERM)

    if counter == 0:
      print("Already stopped.")
  3. Thanks
     

    Here is the output of your bot:

    MySQL has been connected!
    [ RowDataPacket {
        guildID: '700047xxxxx0608151',
        setting: '.',
        value: null,
        createdAt: 2021-03-28T20:31:06.000Z,
        updatedAt: 2021-03-28T20:31:06.000Z },
      RowDataPacket {
        guildID: '775927xxxxx5018378',
        setting: '.',
        value: null,
        createdAt: 2021-03-28T20:50:39.000Z,
        updatedAt: 2021-03-28T20:50:39.000Z } ]
    Aesir-Wolf-Pack#0694 is online!
    
    I edited out some of the guildID in case that's private. Not sure.

    Anyways, since your bot starts just fine, it's up to you from there to log errors yourself from inside the bot's code. Don't rely on console.log(), and definitely don't rely on python. The python just starts the node code, and then disconnects from it to let it run on its own. Just write the logs to a file. Log file permissions can be tricky sometimes for non-linux people. The way I would do it is create an empty file that has write permissions on it and then have the bot append to that. If you have the bot try to create it's own files then you need to worry about directory permissions too, but if the file is already created it's less to figure out.

     

  4. Has anyone had any success logging node.js console.log to a file?

     

    Was reading some other post about having to use home/username/logfile but coming up short

     

    I did try home/mule/debug.log as well just for information

     

    const fs = require('fs');

    var util = require('util');


    var log_file = fs.createWriteStream(__dirname + 'home/mule/node/debug.log', {flags : 'w'});
    var log_stdout = process.stdout;

    console.log = function(d) { //
      log_file.write(util.format(d) + '\n');
      log_stdout.write(util.format(d) + '\n');
    };

     

    attempting to use this information to troubleshoot my code.

     

    potentially better idea to modify start.py to log errors but no clue how to go about doing that.

  5.  

    Please close switched to MySQL.

    You can actually close this yourself. Same for the other topic. Therr should be a link or buttom somewhere that says "Moderation Tools" an6s you can close it that way.

     

    Untagging...

     

     

    I do see text that says "Topic Moderation" but that just says "Lock" would that do the same thing?

  6. Does anyone know where to view Node.js Errors? I tried under cpanel >> errors located under metrics. This doesn't seem to display anything (running a discord bot). I have noticed I can generate some feedback within the start.py "webpage" as in my app.js script I am running console.log commands, but when the script dies I don't have any logs that feedback to the start.py window or the Errors page. I have seen Krydos post logs on the forum before, do we have a page for those? Or if anyone familiar with a way for python to display these errors if (A) leave the start.py webpage up, or (B) have a console.py script that watches for node crashes/or console crashes.  Not positive how this would work in this use case, I would imagine watch console.  But I would also imagine we don't have access to "console".

     

    --GalaxyMule

  7. I feel like i should probably mention I am trying to run a discord bot located at public_html/ae13/app.js as the final goal. This is also tied to the remote postgre database access for some background information.

     

    Issue, fixed node.js is running. Somehow the /node/ folder got deleted and I failed to realize it.

×
×
  • Create New...