You are viewing a single comment's thread from:

RE: Introducing Move Club - Get Rewarded for working out 👣

in #utopian-io7 years ago (edited)

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 bruor now --regions sfo to set your prefered region
then run now scale app-instance-name-here 1 to scale up to min1 :max1

This 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.

Sort:  

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.g

{
  "alias": "move.codewithsam.club",
  "scale": {
    "bru1": {
      "min": 1,
      "max": 1
    }
  }
}

You 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.