Jump to content

Is it possible to use a chat system here?


roguitar

Recommended Posts

 

Failed opening required 'home/roguitar/public_html/chat/vendor/autoload.php'

See how there is no / at the front? Without that leading / it tries to look for a directory called home in it's present working directory. To be an absolute path it needs the / at the start.

 

Yes, you're totally right. I did it, and no error was sent to my email related to this cron job there. But... Anyway... I tried to use the chat system there and it's not working yet... I set the port as 4000, I did that all and nothing. I tried to run the path in the browser https://olimppius.heliohost.org/chat/server/websocket_server.php

and this message has shown:

 

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

 

 

What have I done wrong once more?

I set the cron job to run at 1:15 p.m. today. 

 

I used this command here:

/usr/local/bin/ea-php72 /home/roguitar/public_html/chat/server/websocket_server.php

And I created an .htaccess in /home/roguitar/public_html/.htaccess and inside it we have:

 

RewriteEngine on
RewriteRule ^chat/server/(.*)$ http://127.0.0.1:4000/$1 [P,QSA,L]


#RewriteEngine on
#RewriteCond %{SERVER_PORT} =80
#RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L]


#RewriteEngine On
#RewriteRule ^websocket_server.php/(.*)$ ws://ricky.heliohost.org:80/?$1  [P,QSA,L]

Remember that there is also another .htaccess in /home/roguitar/.htaccess and there is:

 

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

And I don't know if it's making things awkward.

Edited by roguitar
Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

503 means your script on port 4000 isn't running.
 
Also, you only need to do 'RewriteEngine On' once at the very top of the .htaccess. Doing it over and over won't cause an error, but it looks kind of silly.  :blink:

 

I checked your cron jobs, and I don't see anything listed. Did you delete it?

Link to comment
Share on other sites

503 means your script on port 4000 isn't running.

 

Also, you only need to do 'RewriteEngine On' once at the very top of the .htaccess. Doing it over and over won't cause an error, but it looks kind of silly.  :blink:

 

I checked your cron jobs, and I don't see anything listed. Did you delete it?

Yes, I deleted it because I'm afraid of causing problems to myself. Anyway, my plan was to delete it and in the following day (today) set it all again. But I also could set it once and let it run once per day. I'll set it now at 1:15 p.m.

 

Okay, so RewriteEngine On only once, right? I'll then delete the other .htaccess that controls the http/https thing, ok? I think that inside the folder chat/ there must be some file or script where I need to set the port. I don't know what to do, I was thinking of sending my folder to you for you to analyze all the scripts, but I know that you wouldn't do it, and in case you would, you'd certainly charge something for it. So... I'm afraid to ask this.

Link to comment
Share on other sites

 

503 means your script on port 4000 isn't running.

 

Also, you only need to do 'RewriteEngine On' once at the very top of the .htaccess. Doing it over and over won't cause an error, but it looks kind of silly.  :blink:

 

I checked your cron jobs, and I don't see anything listed. Did you delete it?

Yes, I deleted it because I'm afraid of causing problems to myself. Anyway, my plan was to delete it and in the following day (today) set it all again. But I also could set it once and let it run once per day. I'll set it now at 1:15 p.m.

 

Okay, so RewriteEngine On only once, right? I'll then delete the other .htaccess that controls the http/https thing, ok? I think that inside the folder chat/ there must be some file or script where I need to set the port. I don't know what to do, I was thinking of sending my folder to you for you to analyze all the scripts, but I know that you wouldn't do it, and in case you would, you'd certainly charge something for it. So... I'm afraid to ask this.

 

Besides that, the problem persists:

 

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

Link to comment
Share on other sites

I can see your cronjob now, and it looks right. We'll find out if it works in 8 hours and 15 minutes I guess.

No, nothing, nada... It's the same thing:

 

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

 

 

Unless I give you access to check the files in /home/roguiar/public_html/chat/ folder

Link to comment
Share on other sites

Does your script have some sort of exit condition, or should it run forever?

 

EDIT:

 

Why don't you try this:

The other option is you could edit the cron command to change to the correct directory first. The command would be something like this then:

cd /home/roguitar/public_html/chat/server/ && /usr/local/bin/ea-php72 /home/roguitar/public_html/chat/server/websocket_server.php

 

Link to comment
Share on other sites

Does your script have some sort of exit condition, or should it run forever?

 

EDIT:

 

Why don't you try this:

The other option is you could edit the cron command to change to the correct directory first. The command would be something like this then:

cd /home/roguitar/public_html/chat/server/ && /usr/local/bin/ea-php72 /home/roguitar/public_html/chat/server/websocket_server.php

 

 

I think there's no exit condition. It runs forever unless I close the terminal. At least I guess so... Not sure... And ok, I'll try it for tomorrow.

Edited by roguitar
Link to comment
Share on other sites

 

Does your script have some sort of exit condition, or should it run forever?

 

EDIT:

 

Why don't you try this:

The other option is you could edit the cron command to change to the correct directory first. The command would be something like this then:

cd /home/roguitar/public_html/chat/server/ && /usr/local/bin/ea-php72 /home/roguitar/public_html/chat/server/websocket_server.php

 

 

I think there's no exit condition. It runs forever unless I close the terminal. At least I guess so... Not sure... And ok, I'll try it for tomorrow.

 

 

What do you have to say about it?

Link to comment
Share on other sites

Is there any useful information in the email you get when the cron runs?

 

Perhaps it's time to try the cgi method of starting the server since cron doesn't seem to be working? At least that way you can start/stop it as many times a day as you want instead of worrying about exceeding your cron limit.

Link to comment
Share on other sites

Is there any useful information in the email you get when the cron runs?

 

Perhaps it's time to try the cgi method of starting the server since cron doesn't seem to be working? At least that way you can start/stop it as many times a day as you want instead of worrying about exceeding your cron limit.

 

Maybe the cgi method is a bit difficult to me, cuz I don't have any experience.

Link to comment
Share on other sites

You just create a start.py and stop.py cgi scripts based on the idea at https://wiki.helionet.org/tutorials/discord-bot#starting-and-stopping-your-bot Then when you want to start your script you go to domain.heliohost.org/cgi-bin/start.py and when you want to stop the script you go to domain.heliohost.org/cgi-bin/stop.py

 

Like this?

 

To start:

 

 

#!/usr/bin/python3.6


import os, subprocess, signal


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


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


out, err = p.communicate()
for line in out.splitlines():
  if 'websocket_server.php'.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/roguitar/public_html/chat/server/websocket_server.php")
#                         ^^^^^^^^-- be sure to update it to your username


  print("Bot started!")

To stop:

 

 

#!/usr/bin/python3.6


import os, subprocess, signal


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


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


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


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


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

Please, correct me if I am wrong...

 

 

 

 

 

Link to comment
Share on other sites

 

You just create a start.py and stop.py cgi scripts based on the idea at https://wiki.helionet.org/tutorials/discord-bot#starting-and-stopping-your-bot Then when you want to start your script you go to domain.heliohost.org/cgi-bin/start.py and when you want to stop the script you go to domain.heliohost.org/cgi-bin/stop.py

 

Like this?

 

To start:

 

 

#!/usr/bin/python3.6


import os, subprocess, signal


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


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


out, err = p.communicate()
for line in out.splitlines():
  if 'websocket_server.php'.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/roguitar/public_html/chat/server/websocket_server.php")
#                         ^^^^^^^^-- be sure to update it to your username


  print("Bot started!")

To stop:

 

 

#!/usr/bin/python3.6


import os, subprocess, signal


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


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


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


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


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

Please, correct me if I am wrong...

 

 

 

 

 

 

 

I've tried the code above and the page is blank. And I believe nothing is running.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...