I have problem with date format in laravel model for different operating system (windows & linux) SQL Server
How to get the value from env to model, I create variable in .env for set condition in model when value variable environment 1 = windows and 2 = linux
// 1 FOR WINDOWS
// 2 FOR LINUX SERVER
ENVIRONMENT=1
Any solution / advice for this case?
All variables in your .env files are parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the env() function.
make sure you already execute this command to clear your config after you added that variable to your config.
php artisan config:clear
Retrieving Environment Configuration
<?php
$environment = env("environment", 1)
?>
The second value passed to the env function is the "default value". This value will be used if no environment variable exists for the given key.
see docs here env
in Laravel function env() returns values from .env file.
So if you have ENVIROMENT = 1 in your .env, using env('ENVIRONMENT'), you will get that value.
Related
I am trying to deploy a model that i have registered. I registered the model using the following code:
step_register = RegisterModel(
name="RegisterCustomModel",
estimator=estimator,
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
content_types=["text/csv"],
response_types=["text/csv"],
inference_instances=["ml.t2.medium", "ml.m5.large"],
transform_instances=["ml.m5.large"],
model_package_group_name=model_package_group_name,
approval_status=model_approval_status,
model_metrics=model_metrics,
)
However, I am getting an error when i deploy this model which I believe is because the environment variable SAGEMAKER_SUBMIT_DIRECTORY is not set.
My question is, can I set the environment variable SAGEMAKER_SUBMIT_DIRECTORY in the RegisterModel function and if I can, how do I do that?
I am using App engine, and I'm trying to get the time zone from the request.
However when on local host it always seems to return 'ZZ' as the country code which is not a country in pytz library.
This code:
country = self.request.headers['X-Appengine-Country']
logging.info(country)
tz = pytz.country_timezones(country)
produces this error:
return self.data[key.upper()]
KeyError: 'ZZ'
many thanks for your help
'ZZ' is often used to denote 'Unknown or unspecified country'
There is also a numeric version of the two letter code, calculated as 1070+30a+b, where a and b are the two letters of the code converted by A=1, B=2, etc. So AA=1101, AB=1102, BA=1131, and ZZ=1876.
I suggest that you use the correct case for the Request Header names. For e.g. X-AppEngine-Country
However, in the local development environment - I do not think the Location features will be supported i.e. you will not get the correct values. These should work only on the deployment environment. The Location is most likely provided by a Google Service that is internal to the Google Network and not exposed in the Local Development Environment.
Try to deploy your code to the live environment and check the values.
I am using Nagios Core 3.5.0 and I have the following service definition:
service {
...
action_url http://$USER10$/static/html/node.html?node=$USER3$&host=$HOSTADDRESS$
}
The USERxx variables have been set correctly in resource.cfg.
However, the URL that gets generated does not get the value at all for the USER variables but gets the value for HOSTADDRESS.
Is there something that I need to do to all USER variables to be available for the action_url and notes_url?
The USER variables should definitely be available, as per here: Nagios 3.x manual
In fact, we're running Nagios 3.5.1 and have successfully done this to link to pnp4nagios graphs:
define host {
name host-pnp
action_url $USER10$?host=$HOSTNAME$
register 0
}
Have you defined the resource.cfg in your nagios.cfg correctly using something like this?
resource_file=/usr/local/nagios/etc/resource.cfg
My guess is that you've not defined the resource file correctly, so the macros are not being defined.
I have a folder in my d drive.files in this drive i am using in my controller.so in controller i am specifying tht folder name for to each file recurse.But after development files may be saved in any other drive.so I want have environment variable for it.how to do that
It sounds like a configuration parameter would be better than an environment variable. Config.groovy is environment aware, so you can specify different values for development, production, etc.
environments {
production {
fileLocation = "D:/"
}
development {
fileLocation "/somewhere/else"
}
test {
fileLocation "/production/somewhere"
}
}
You can read the value of this parameter with:
def fileLocation = org.codehaus.groovy.grails.commons.ConfigurationHolder.config?.fileLocation
in grails 1.4 ConfigurationHolder is deprecated, so you should read config parameters using this instead:
def fileLocation = grailsApplication.config.fileLocation
Is there a simple way to get the current serving application version in AppEngine?
os.environ['CURRENT_VERSION_ID']
String version = SystemProperty.version.get();
String applicationVersion = SystemProperty.applicationVersion.get();
This is the syntax:
public static final SystemProperty applicationVersion
The major version number for the currently running version of the application plus a timestamp at which it was deployed. Has the key, "com.google.appengine.application.version".
See here
PS. One puzzle still remains. What does timestamp next to version means and how to read it??
EDIT: Here is the key to the mystery.
Date UploadDate = new Date(Long.parseLong(
applicationVersion.substring(applicationVersion.lastIndexOf(".")+1))
/ (2 << 27) * 1000);
For Python (GAE SDK release: "1.4.2")
version_id = self.request.environ["CURRENT_VERSION_ID"].split('.')[1]
timestamp = long(version_id) / pow(2,28)
version = datetime.datetime.fromtimestamp(timestamp).strftime("%d/%m/%y %X")
See http://groups.google.com/group/google-appengine-python/browse_thread/thread/f86010e7cf3c71b4
from google.appengine.api import modules
modules.get_current_version_name()
Source: https://cloud.google.com/appengine/docs/python/modules/functions
For nodejs, I am not sure if this is documented.
process.env.GAE_VERSION
You can also access the process' environment variables:
GAE_VERSION
which is available when you deploy (gcloud app deploy) using the flag --version
For those who want an update, environment variables set for a GAE instance as of September 2020:
GAE_VERSION is the one that seems to answer the original question.
Google doc:
https://cloud.google.com/appengine/docs/standard/python3/runtime#environment_variables
The following environment variables are set by the runtime:
Environment variable Description
GAE_APPLICATION The ID of your App Engine application. This ID is prefixed with 'region code~' such as 'e~' for applications deployed in Europe.
GAE_DEPLOYMENT_ID The ID of the current deployment.
GAE_ENV The App Engine environment. Set to standard.
GAE_INSTANCE The ID of the instance on which your service is currently running.
GAE_MEMORY_MB The amount of memory available to the application process, in MB.
GAE_RUNTIME The runtime specified in your app.yaml file.
GAE_SERVICE The service name specified in your app.yaml file. If no service name is specified, it is set to default.
GAE_VERSION The current version label of your service.
GOOGLE_CLOUD_PROJECT The Cloud project ID associated with your application.
PORT The port that receives HTTP requests.
Based on my experiments today, there are two os.environ variables that you can use to get the current app version:
os.environ['GAE_VERSION']: the version name only
os.environ['CURRENT_VERSION_ID']: a unique version identifier composed of {version name}.{deployment id}, which is equivalent to os.environ['GAE_VERSION'] + '.' + os.environ['GAE_DEPLOYMENT_ID']
It appears that the so-called "deployment id" can be right-shifted 28 bits to get a timestamp in epoch seconds (as other answers already described).
For example: I deployed version "101" of my app at 2021-03-04T00:17:12Z and I'm seeing the following values:
os.environ['GAE_VERSION']: '101'
os.environ['CURRENT_VERSION_ID']: '101.433474146608888597'
os.environ['GAE_DEPLOYMENT_ID']: '433474146608888597'
You can use the following code to get the version name and timestamp from os.environ['CURRENT_VERSION_ID']:
>>> import os
>>> import datetime
>>> version_id = os.environ['CURRENT_VERSION_ID'] # example: '101.433474146608888597'
>>> name, ts = version_id.split('.')
>>> dt = datetime.datetime.utcfromtimestamp(int(ts) >> 28))
>>> dt.isoformat()
'2021-03-04T00:17:12'
Disclaimer: Most of this functionality is undocumented and the deployment ID format may be subject to change.