AppMaker: environment variables per deployment ? Get the deployment name? - google-app-maker

Some times ago I asked this: How to check in both server-side and client-side scripts if we are in preview mode or deployed version
Because I wanted in my code to have different logic whether it is the preview mode or not.
The answer was "preview mode is just another deployment and each deployment has its own Drive table, store some env variables there". That was true and made the trick.
Problem: Drive tables don't exist anymore.
I have not been working with AppMaker the past months so maybe I have missed new features:
how can I set environment variables per deployment ? (so I can make a
difference between my prod deployment and my pre-prod deployment)
is there a way to get the current deployment name from the code ?
Thanks for your answers

Deployment unique environment variables can be stored using the Google script properties service.

This is an undocumented solution. It's not the best and neither recommended for long term usage because it can change in the future, however, to answer your question directly, you can get the deployment name via server scripting. Put the following on a server script:
function getDeployment() {
var deploymentName = app.a.a.a[13].name;
return deploymentName;
}
Then insert a button in the UI, add the following to the onClick event handler of the button:
google.script.run.withSuccessHandler(function(result){
console.log(result);
}).getDeployment();
Preview the app, test it and you should get Preview. Publish the app to a deployment and test it, you should get the deployment name. I hope it helps!

Nothing has changed with SQL. The preview and deployment work with separate data sets. It is enough to put one setting record in a table and assing deployment or preview value respectively. Each new preview will work with preview data and each new deployment will work with life data.

Related

How to Differentiate Staging/Dev and Production Build for Android/IOS in Google Firebase for Analytic and Crash

Recently I have Added the my Android and iOS project to Firebase with alpha version.I want to See different Analytic and Crash for Staging and Production. Can anyone help on this.
Thanks
You have several options, depending upon what your needs are. The bottom line is that you should, at the very least, assign different application IDs to the different variants of your app, so they can be separate in the Firebase Console. You can have multiple apps per project (each assigned a different ID), or multiple projects with an app in each one, depending upon what works best for your team and your app.
The actual implementation can get complicated from here on out, so I suggest you read this blog post to learn about the options for your Android app, and how it affects the operation of the various Firebase features in that app.
I think of 2 ways to do so:
Using app version + date range: If you know your app in staging was version X from day N to N+10, you can select theses filter in Firebase analytics to display only the analytics coming from that configuration. This also work for crash reporting.
I prefer: Using a remote config & user property:
Setup in remote config a key as "environment" with some values like "alpha", "beta", "prod". You can then specify the value per platform/app version.
On the phone, read that value in remote config and track a user property in Firebase Analytics that reflect that value.
Finally in the Firebase console you can filter by user property (& app version if necessary).
With this option, when you move an app version out of alpha to beta (for instance) you just need to go in remote config, and change the value for that app version to "beta". This solution doesn't work for crash reporting.
You can use a different Firebase project for each stage so that the analytics are completely distinct. See more on that in the response to this question.
Create a user property Environment, give values such as Dev, Staging and Prod to it on build time.
Change the user property from client side to any of the above three mentioned values based on the build type.
Apply filter by Environment user property on firebase console to see the analytics data.

MeteorJS application not working once deployed on MeteorJS cloud

I deployed my MeteorJS web application (http://caloriecounter.meteor.com/) but for some reason it is not working. User should be able to sign in/sign up and be able to add meals and the meals should be displayed under the date in a table once the meals are added.
It is working locally but I'm not sure why its not working once I deployed it. I've been attempting to look at possible errors and I've looked at the console under developer tools but there seems to be nothing coming up there either.
So I'm a little lost on what is exactly going on. Please advise.
I just think of different data on server vs. your local instance. Maybe your code require certain data to be available.
My suggestion:
Reset your local instance (note: your local database will be cleaned!): $ meteor reset
or just create a local copy with empty database

Rapid CSS Testing with JSP

I am new to web development and am unfamiliar with some of the methods for best testing the web end information. On my current project I am using Weblogic to deploy my JSP project through Eclipse.
The webpages build fine and everything works, but currently I am restarting my localhost server every time I make a change to the css or the jsp, which a single round trip can be up to 3-5 min. is there a more efficient way of testing the css other than restarting my server every time? What about jsp?
Edit: Followup:
For any that stumble past this: After reading up on different staging methods as #better_use_mkstemp suggested, I couldn't figure out how to explicitly set eclipse up to stage or nostage deploy, however I did find some nifty things.
You can do an Incremental push (expand drop down in the servers view in eclipse, right click project that is deployed on a running server > click "Incremental Publish". This only pushes what has changed since last push) which helps a bit.
The other thing I found was an automatic deploy when a file changes, but that had it pushing while I was still editing the file which was a bit annoying. Using this feature you can also have it auto deploy each time there is a new version, but I didn't play around with that since we're not changing the version number yet.
Check how you are deploying your application. If you deploy using nostage mode, the server(s) will keep looking in the original deployment directory and will automatically detect jsp changes for refreshes.
This is as opposed to stage mode, where the original war/ear deployment is actually copied to each individual server.
Read more here: http://docs.oracle.com/cd/E11035_01/wls100/deployment/deploy.html#wp1027044
Sounds like if you keeps dropping your updated deployment files in the same directory with nostage you won't need a restart.

Setting up diagnostics for Windows Azure Web Role

I have recently deployed my web role to Windows Azure. In the properties of my WebRole I have set Enable Diagnostics.
I can also see that it correctly maps to a storage account once deployed by viewing the configuration file of the hosted service.
I have not setup anything else for diagnostics, I am unaware that I need to do anything else.
I am now setting up AzureWatch (by paraleap) to monitor my instances however it reports that WADPerformanceCountersTable does not exist.
I am very new to Azure, don't have a clue how the diganostics work and can't find anything on Google that shows me how. Could someone please show me the way.
Ok I figured it out and will leave this here for others to follow.
Step 1
If you follow http://dunnry.com/blog/2012/02/27/SettingUpDiagnosticsMonitoringInWindowsAzure.aspx Windows Azure Diagnostics will start saving data into your attached Blob storage, full of diagnostic information.
Special Note: These count towards your storage transaction, which is why you will see them go up.
Step 2
However I needed the WADPerformanceCounterTable, which should have been located in the tables section of the storage account but it never was created. I needed this to use services like AzureWatch to monitor and spin up or down instances.
Special Note: This is performance counters, a specific subset of diagnostic information and this isn't stored in the blob section by default.
Step 3
In your project you need to add which performance counters to monitor in the WebRole.cs.
Special Note: You won't have this if you just added an existing project to an Azure deployment project. Unless you specifically started the project from scratch and chose the Azure templates, you will need to create this manually. You would also need to add: Microsoft.WindowsAzure.Diagnostics, Microsoft.WindowsAzure.ServiceRuntime and Microsoft.WindowsAzure.StorageClient as References. Best way to see how it all works is to create a blank project from an Azure template and copy over the necessary items.
Step 4
Next you need to define which performance counters to monitor. As such here is a great sample: http://code.msdn.microsoft.com/windowsazure/Windows-Azure-PerformanceCo-7d80ebf9
Extra Reference
Microsoft also has a few steps you can follow here that might help out if things still aren't working: http://msdn.microsoft.com/en-us/library/windowsazure/hh411521.aspx
Take a look at:
http://dunnry.com/blog/2012/02/27/SettingUpDiagnosticsMonitoringInWindowsAzure.aspx
There is also a lot of information on:
http://msdn.microsoft.com/en-us/library/windowsazure/gg433048.aspx

How to automate the build process?

How can I automate the web-application build process, that includes following steps:
Change connection string.
Recreate database by scripts.
Deploy web-site by ftp.
Copy some files to server in addition to application.
And may be perform some initialize operations.
Should I write any script/programm, use Visual Studio or any another program?
Personally I use a Continuous Integration tool to do this kind of work.
The one I mainly use is Team City by JetBrains.
This kind of software can look at your Source Control repo for new checking, perform builds, publish builds to servers as well as running pre/post build events.
You've to start learning MSBuild. It is VERY simple and straightforward, so just start and you'll see ;)
In adddition to built in features it has Community Pack with many tasty things so you will be able to:
Replace connection string in config file using regex or replace whole config with predefined connection string (FileUpdate or Copy task)
Execute database scripts (MSBuild.Community.Tasks.SqlServer.ExecuteDDL)
Deploy site using Copy task
And many other...
You can run pre and post events in Visual Studio. To do this, simply right click on the project and in the project properties navigate to the 'Build Events' options. Here you can specify the pre and post build events (you can also specify when the event runs - on successful build or otherwise).
Once the project has been successfully built, the post build event can be set up to perform the tasks specified. You can detail the steps either in a separate file or in Visual Studio project's build events itself.
More information
Pre/Post Build event command line arguments
How to: Specify Build Events (C#)
Much along the continuous integration concept Jamie mentions, we use BuildMaster internally for all of our applications since we develop it :)
Now that we have a version offered for free, I'll share some thoughts on each of your bullet points:
Change connection string
This is something that is handled uniquely by the tool. Each environment would get its own "instance" of a configuration file and in a deployment plan you can use the "deploy configuration files" action to put them in any environment. This means there are no transforms to worry about since the config file is stored and versioned within the tool.
Recreate database by scripts
This is another major feature we have. Object code (stored procs, views, etc.) can be run every time with a DROP/CREATE combo, but adding indexes, dropping columns, can only be done once (you can't bring a column's data back without a restore!)
BuildMaster handles these types of change scripts differently - they can only be run at most once against an environment's instance of your database. This makes it super easy to bring any new or existing initialized database schema up-to-date.
Deploy web-site by FTP
Just add an action to your deployment plan, and you click Create Build or Promote Build, it will do that.
Copy some files to server in addition to application
If the process is repeatable you can do this easily, if need be by using a manual action that will remind you to do it.
And may be perform some initialize operations
This sounds like a "change control" to me, a one-time change when you release. We support these as well but not in the free version unfortunately.

Resources