I use symfony 1.4. And I use task for email reporting, before retrieving sfMailer i create sfContext instance, but during creation symfony output this lines to the console:
>> sfPatternRouting Connect sfRequestRoute "sf_captchagd" (/captcha)
>> sfPatternRouting Match route "homepage" (/) for / with parameters array ( 'module' => 'main', 'action' => 'index',)
As you can see, sfContext create routing stuff and probably other unnecessary things - i need just two things: partial templates and sfMailer instance thats all.
Here is the lines when i create sfContext instance:
sfContext::createInstance($this->configuration);
sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
The easiest way is to create a new evironment in your factories.yml and settings.yml with only the things you need. It doesn't need to have a php script in the web directory, only a definition in the factories.yml and settings.yml same as dev and test and stage environments. And when you load the context configuration use that environment. In your own mailer environment you can disable routing, cache, and other parts of the framework.
Related
My property file name is dev_123.yaml.
dev is an environment variable called env.
123 is a value coming from query param called rollId. Am storing this value in vars.rollId.
In configuration properties component, under 'file' field it will work if I give ${env}_123.yaml.
However, I want to read the value of '123' dynamically via vars too. I tried the following but dint work:
#[p('env') ++ "_" ++ vars.rollId ++ ".yaml"]
${env}_${vars.rollId}.yaml
That will not work. Configuration properties and configuration files are resolved at the startup of a Mule application. Variables are defined during flow execution, after application startup. There is no way to set a variable during start-up. Using configuration properties in the properties file name works because they are resolved at the same time.
An alternative could be to create a custom Mule Module with Mule SDK that implements operations to read properties files dynamically during flow execution. You have to consider if it worth the effort.
I have base /config/services.yaml which stores many services in my Symfony 4.3 project. For example:
My\Namespace\Service:
- '#My\Namespace\Dependency'
For my test purposes, I have config/test/test_services.yaml where I store services with 'test.' prefix to test private services, making them public in test env.
One of the services, declared in test_services.yaml has no prefix. It is identical by its name (FQCN) to another one defined in services.yaml. They have different constructor arguments of the same type.
Test one (/config/test_services.yaml) has mocked dependencies returning fixtures data:
My\Namespace\Service:
- '#My\Namespace\MockedDependency'
Is there a way to prevent service override to not replace mocked service with real one during test execution in test env?
Solution for this situation is create services_test.yaml file and place it under /config folder along with services.yaml.
In that case, symfony will not override service and will use one defined in services_test.yaml during tests execution
Environment
ASP.NET WebForms app over IIS
Docker container host
AWS ECS hosting platform
Each client hosting its own copy of the app with private database connection string
Background
In the non-docker environment, each copy is a virtual directory under IIS, and thus have their own individual web.config pointing to dedicated databases. The underlying codebase is the same for each client, with no client-specific customization involved. The route becomes / here.
In the docker environment (one container per client), each copy goes over as a central root application.
Challange
Since the root image is going to be the same, how to have the web.config overridden for each client deployment.
We shouldn't create multiple images (one per client) as that will mean having extra deployment jobs and losing out on centralization. The connection strings should ideally be stored in some kind of dictionary storage applicable at ECS level which can provide client-specific values upon loading of corresponding containers.
Presenting the approach we used to solve this issue. Hope it may help others struck in similar cases.
With the problem statement tied to having a single root image and having any customization being applied at runtime, we knew that there needs to be a transformation of web.config at time of loading of the corresponding containers.
The solution was to use a PowerShell script that will read the web.config and get replace the specific values which were having a custom prefix embedded to the key. The values got passed from custom environmental variables within ECS and the web.config also got updated to have the keys with the prefix added.
Now since the docker container can have only a single entry point, a new base image was created which instantiated an IIS server and called a PowerShell script as startup. The called script called this transformation script and then set the ServiceMonitor on the w3cwp.
Thanks a lot for this article https://anthonychu.ca/post/overriding-web-config-settings-environment-variables-containerized-aspnet-apps/
I would use environment variables as the OP suggests for this with a start up transform, however I want to make the point that you do not want sensitive information in ENV variables, like DB passwords, in your ECS task definition.
For that protected information, you should use ECS secrets coupled with Parameter Store in Systems Manager. These values can be stored encrypted in the Parameter Store (using a KMS key) and the ECS Agent will 'inject' them as ENV variables on task startup.
For me, to simplify matters, I simply use secrets for everything although you can choose to only encrypt the sensitive information and leave the others clear.
I dynamically add the secrets for the given application into my task definitions at deploy time by looking up the 'secrets' for the given app by 'namespace' (something that Parameter Store supports). Then, if I need to add a new parameter, I can just add a new secret to the store in the given namespace and re-deploy the app. It will pick up and inject into the task definition any newly defined secrets automatically (or remove ones that have been retired).
Sample ruby code for creating task definition:
params = ssm_client.get_parameters_by_path(path: '/production/my_app/').parameters
secrets = params.map{ |p| { name: p.name.split("/")[-1], value_from: p.arn } }
task_def.container_definitions[0].secrets = secrets
This last transform injects the secrets such that the secret 'name' is the ENV variable name... which ends up looking like this:
"secrets": [
{
"valueFrom": "arn:aws:ssm:us-east-1:578610029524:parameter/production/my_app/DB_HOSTNAME",
"name": "DB_HOSTNAME"
},
{
"valueFrom": "arn:aws:ssm:us-east-1:578610029524:parameter/production/my_app/DB_PASSWORD",
"name": "DB_PASSWORD"
}
You can see there are no values now in the task definition. They are retrieved and injected when ECS starts up your task.
More information:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html
I got newly created Magnolia instance. I tried to create an app via bundled groovy script and publish news to public instance. I got this error
It happened because 'ebtnews' workspace is not synchronised from author to private. So the question is how to sync workspace from author to private?
What I do is every time I added a new workspace in the module definition xml for my author instance, I make sure I also added this workspace in the module definition xml for my public instance. Then need to restart both author and public instance for it to create the new workspace.
Alternatively, you can just run following via groovy console/script:
// create workspace
Components.getSingleton(RepositoryManager.class).createWorkspace(app_repository, app_workspace)
// check we registered all right
appSession = ctx.getJCRSession(app_workspace)
// register node type
nodeTypeManager = appSession.getWorkspace().getNodeTypeManager()
type = NodeTypeTemplateUtil.createSimpleNodeType(nodeTypeManager, app_node_type, Arrays.asList(NodeType.NT_HIERARCHY_NODE, NodeType.MIX_REFERENCEABLE, NodeTypes.Created.NAME, NodeTypes.Activatable.NAME, NodeTypes.LastModified.NAME, NodeTypes.Renderable.NAME))
nodeTypeManager.registerNodeType(type, true)
appSession.save()
// double check it registered all right
nodeTypeManager.getNodeType(app_node_type)
You will also want to register basic security rights for the workspace, set it under subscriber workspace mapping to enable activation and possibly include/exclude it from list of triggers for flushing cache upon update of content on public instance.
You can find code to do all that in createAppScript sample script in groovy module. Code I've pasted above is actually from the same script.
Advantage being that you can do all that at runtime w/o restart. Disadvantage, that you need to run same code on each instance.
I am using SignalR to build Real time application
I have added the following code to application start in the global.asax file
'Register the default hubs route: ~/signalr
RouteTable.Routes.MapHubs()
and I got the following error:
A route named 'signalr.hubs' is already in the route collection. Route names must be unique.
Parameter name: name
It's most likely you are calling this twice. Check all your code that this is not the case, including any App_Start code. Do a global search within your app for "MapHubs".
Also check you have only one version of Signal installed (older versions had a different namespace).