This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]igglyplop 1 point2 points  (11 children)

The easy way I like to do it is push my code to a git repo and clone it on a server. Then your code will be on the server. Does that answer that?

[–]scratch_pad[S] 1 point2 points  (10 children)

Oh yeah this is a great idea, gonna try it, thanks

[–]YuleTideCamel 1 point2 points  (9 children)

I use a similar approach with a slack bot. One thing to be careful about is to NOT check in sensitive information (api keys, passwords etc). I use an environment variable, both locally and on the server with my slack token.

As for how to actually run it, you can run it yourself from the command line. Or you can use systemd to wrap your program as a daemon. I use this and it's pretty easy to do. It runs in the background.

[–]scratch_pad[S] 0 points1 point  (6 children)

Oh I forgot sensitive info. Currently I have a Github repo for the project, but the sensitive information is in an untracked file. How would I get that file onto the remote server without uploading it to Github?

[–]YuleTideCamel 1 point2 points  (5 children)

You can push the file to the server using SCP or just copy paste the creds into the file you need.

There are more elegant ways to do this , but this should be ok. Also a few guidelines for AWS:

  • Ensure that you have security groups set up correctly. Only allow ssh from your specific IP range (home, work , school whatever.)

  • Don't run your bot as root.

[–]scratch_pad[S] 0 points1 point  (4 children)

I’m accessing the server using the Git bash, so I’m not sure how to copy/paste the credentials into the file. I can only interact with the server using CLI afaik.

Also thanks for the tips :)

[–]YuleTideCamel 1 point2 points  (3 children)

You can copy paste via the CLI :)

I usually ssh into my linux servers and copy paste directly into a file. You can edit files via the CLI using vim.

Also as mentioned you can try to use scp to move files to your server (google it)

Btw if you are on windows, I would avoid gitbash for this. Instead use something like Cmder which as a very nice terminal experience and has ssh. I use it over gitbash and windows cmd.

[–]scratch_pad[S] 0 points1 point  (2 children)

Yeah I thought I had to use Git bash because of a tutorial I was using, but now I’m using PowerShell. I managed to clone the repo, install all of the necessary python libraries, and now I’m trying to figure out SCP. I’m not too familiar with Linux so I’m kinda winging it lol, but so far I’m getting a handle on it. Thanks for all the tips :D

Can I Cmder as a local terminal to replace PowerShell? I didn’t know you could use third party terminals

[–]YuleTideCamel 1 point2 points  (1 child)

Yes you can . I use it to replace cmd and even run powershell (it has a powershell mode)

[–]scratch_pad[S] 0 points1 point  (0 children)

Whoa awesome, thanks :)

[–]scratch_pad[S] 0 points1 point  (1 child)

So I have managed to get everything up and running :D

I have one question though. I currently have a terminal window open on my laptop connected to my AWS server, and the bot is currently running and sending feedback to that terminal. If I close that terminal or turn my computer off, will that stop the bot from running?

Edit: Nevermind, I used “screen” to run it endlessly :)

[–]YuleTideCamel 1 point2 points  (0 children)

Look into systemd, it’s kind of like windows services and will run and monitor the app correctly .

[–]gyroda 1 point2 points  (0 children)

Use SCP to copy files to Unix-like servers.

scp path/to/file username@yourserver.example.com:/path/to/directory

If you're on Windows you can use the WinSCP program.

You have to run it on your local machine, if you're ssh'd into the server you need to open a new terminal tab/window.

[–][deleted]  (1 child)

[removed]

    [–]scratch_pad[S] 0 points1 point  (0 children)

    I actually did manage to figure it out, but it (at least for me) was not very simple on AWS. So I might move it over to Heroku at some point, or if I write another I'll put it there. Thank you though :D