RE: Introducing Move Club - Get Rewarded for working out 👣
Hi Sam,
Wow! your a popular person, so many people asking you questions. How the heck do you keep up?
Just to add to the load @aussieninja dobbed you in a couple of times to me and said your the go to for all things good and bots.
I'm having some trouble hosting my node.js code bot with remote server Zeit. It seems by design the instance goes to sleep after 1 hour. (By design if you read the Zeit self help it says this is the case for non scaled instance). So unless you scale 1 your instance, your steemit bot will go to sleep after 1 hour with no activity. Unfortunately I cannot scale the instance as that would result in two copies of the bot running simultaneously and I need to store a variable (The two will get confused - not to mention RPC timeout things as they both try to respond/post at once). Is there anyway to turn of the auto sleep for Zeit..and if not, do you have a simple/clever bit of code that could...I don't know, scan the block chain in a way that Zeit registers it as traffic and thus doesn't go to sleep. The normal steem.api.streamTransactions('head' thing doesn't do it.
The only thing I can think to do is every 30 mins right to a dummy post! but this would junk up Steemit! even if the post is really old past payout. My code works fine on local server and doesn't go to sleep.
Cheers for thoughts, if you some how get the time to read this :)
P.S I have min programming experience, just recently taught myself with occasional bit of help here and there.
also top effort for getting into programming and learning yourself 👊
..Cheers, allot of patience is needed and trial and error. I wouldn't be able to learn with out people like yourself or Aussieninja helping along the way. huge thanks.
hey 👋
You're right, the instances do sleep after some time. By default, instances are set to min: 0 max:1, meaning they will sleep. You can set it to min:1 max1 so it won't sleep but also will not be more than 1 instance running(which would interfere with your bot etc). Recently Zeit added support for running in multiple regions, which has the added side effect that now you need to specify to run in only one of those regions or it will run an instance in both by default.
run
now --regions bru
ornow --regions sfo
to set your prefered regionthen run
now scale app-instance-name-here 1
to scale up to min1 :max1This should mean you have one instance running on zeit forever you run
now scale ap-name 0
or update the app.Let me know if that works, shouldn't need to do any trickery with your actual code.
Thanks mate, will try out at nearest chance and let you know. Greatly appreciated.
Ok, so step 1 works. now --regions bru...
step two appears to work now scale...app... 1 and it displays this:
Scale rules for bru1, sfo1 (min: 1, max: 1) saved [6s]
So so far so good (although I'm guessing that it saying 2 regions in result not good?), anyways if I login to the website though it says...something else, it says..
You updated scale rules for app...now.sh to min: 2, max: 2 in
US West (SFO)
Hey I never asked for 2? and it didn't say it deployed 2, let me look in the log:
Yeah, it is running twice and my bot interfered with :(
Ok, so I assume not working as expected but just in case I'll run your last suggested command:
now scale ap... 0 , it says:
You updated scale rules for ...app.now.sh to min: 0, max: 0 in
US West (SFO)..
Yeah unfortunately the app is now turned off.
Sorry mate..doesn't work. Thanks though for trying.
My best thought is while the original command to set region to bru worked, the moment you use the scale command it pops it back into both regardless (not just by default). Or something weird with something else I'm doing (possible :))
When I tested
now --regions bru
yesterday It worked as expected but today it ignores it and sets up both (like you noticed). This is an issue, it's clearly stated in the docs what is the expected behaviour.Instead of that we can do it a different way. Add a scaling rule to your
now.json
file if you have one, if you don't then create it at the root level of your project folder. e.gYou can see here I have an alias rule and a scale rule. You don't need the alias rule this is just to show you my now.json file.
When running
now
it should automatically only deploy to the specified region with exactly one instance.The last command
now scale app-name 0
- does exactly that, it scales your app to zero instances. Don't run that command unless you want to stop your app running.Thanks heaps - will give it a shot tomorrow and let you know.
Sort of worked, created now.json file (just removed alias bit)..it seemed to go up ok, no message at all on instances (but unusual normally it says something, even if it's wrong)...but when i go to website says 0 instances. So yeah looks like it loaded up the code but no active instance.
if I scale to 1 it says Error! cannot scale with a static deployment.
it's a little tricky to help without knowing how your code is structured. Static developments are ones that use .html files directly rather than being served via an app.
If it thinks you're running a static development and it's actually for one of your bots then something else is wrong.
is your bot a single .js file?
Yep it's a single file.js file... I think I might know what happened, chance I stuffed up the key thingy, but wouldn't have thought it do that...basically I taught myself to use the package.json approach and inside that you can have a now section. As I have moved to your now.json file approach (can't use both it complains), i think it might been confused around the key portion. I'll have another play, combining your now.json into the package.json instead, i will have a see if autobots are go then :)...if not i might pop back and show you my package.json code, it might make more sense then. Will be a week or so as got too much on the go now and using bot via remote server. I'm not sure if you chat to others on discord, but if you do my name is nigelrhil, Also can see my bot in action here running on local server. It's a simple competition on Steemit I keep evolving the bot/my skills with each iteraction. I've never done anything like this b4, but trying my best to do something different, so really appreciate the support. Cheers.
..Also an app that pays me Steem for working out...where do I sign!
Ah.... you can start by getting involved in Move Mob young man!
I'm down for that, will read up this weekend :)
Psst IBT#6 is running if keen - time to checkout the bot in action again hehe