I have a website I am currently working on in clojure. The local version of the site works perfectly, but when I push it to heroku, it is unable to find any of my static resources. I've checked, and git is including the resources/public folder, so it should be getting uploaded to heroku.
Here is my handler code:
(defroutes app
(GET "/" [] (layout/application "Home" (content/index)))
(GET "/commission" [] (layout/application "Commission Calculator" (content/commissionForm)))
(POST "/commission" [report] (layout/application "Commission Calculator" (content/commissionResults report)))
(route/resources "/"))
The resources directory is at the same level as the src folder, and the assets are named correctly. The project is located here.
Navigating directly to https://lit-falls-39572.herokuapp.com/css/master.css, results in a 404 error, but navigating to localhost:5000/css/master.css correctly returns the css content, when I host the site locally. (Navigating to either /resources/public/css/master.css or /public/css/master.css does not work either) Does anyone have any idea why it would be behaving differently on heroku?
Edit: Here is the project stucture:
├───.idea
│ ├───copyright
│ ├───inspectionProfiles
│ └───libraries
├───dev-resources
├───lib
├───resources
│ └───public
│ ├───CSS
│ ├───images
│ │ └───home
│ └───material-design
│ ├───css
│ ├───img
│ │ ├───examples
│ │ └───flags
│ ├───js
│ └───sass
│ └───material-kit
│ └───plugins
├───src
│ └───kandj
│ └───views
├───target
│ ├───classes
│ │ └───META-INF
│ │ └───maven
│ │ └───kandj
│ │ └───kandj
│ └───stale
└───test
The issue is that your CSS directory has upper case name while your URLs use css lower case.
Related
Gurus!
I'm under developing Terraform modules to provision NAT resource for production and non-production environment. There are two repositories one for Terraform modules another for the live environment for each account (ex: dev, stage, prod..)
I have an problem when access output variable of network/nat module.
It makes me very tired. Please refer below.
for Terraform module (sre-iac-module repo)
❯ tree sre-iac-modules/network/nat/
sre-iac-modules/network/nat/
├── main.tf
├── non_production
│ └── main.tf
├── outputs.tf
├── production
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
└── variables.tf
for live environment (sre-iac-modules repo)
❯ tree sre-iac-modules/network/nat/
sre-iac-modules/network/nat/
├── main.tf
├── non_production
│ └── main.tf
├── outputs.tf
├── production
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
└── variables.tf
In the main code snippet, sre-iac-live/dev/services/wink/network/main.tf
I cannot access output variable named module.wink_nat.eip_ids.
When I run terraform plan or terraform console, always I reached following error.
│ Error: Unsupported attribute
│
│ on ../../../../../sre-iac-modules/network/nat/outputs.tf line 2, in output "eip_ids":
│ 2: value = module.production.eip_ids
│ ├────────────────
│ │ module.production is tuple with 1 element
│
│ This value does not have any attributes.
╵
Here is the ../../../../../sre-iac-modules/network/nat/outputs.tf and main.tf
output "eip_ids" {
value = module.production.eip_ids
# value = ["a", "b", "c"]
}
----
main.tf
module "production" {
source = "./production"
count = var.is_production ? 1 : 0
env = ""
region_id = ""
service_code = ""
target_route_tables = []
target_subnets = var.target_subnets
}
module "non_production" {
source = "./non_production"
count = var.is_production ? 0 : 1
}
However, if I use value = ["a", "b", "c"] then it works well!
I couldn't re what is the problem.
Below is the code snippet of ./sre-iac-modules/network/nat/production/outputs.tf
output "eip_ids" {
value = aws_eip.for_nat[*].id
# value = [aws_eip.nat-gw-eip.*.id]
# value = aws_eip.for_nat.id
# value = ["a", "b", "c"]
}
Below is the code snippet of ./sre-iac-modules/network/nat/production/main.tf
resource "aws_eip" "for_nat" {
count = length(var.target_subnets)
vpc = true
}
And finally, here is the main.tf code snippet. (sre-iac-live/dev/services/wink/network/main.tf)
module "wink_vpc" {
.... skip ....
}
module "wink_nat" {
# Relative path references
source = "../../../../../sre-iac-modules/network/nat"
region_id = "${var.region_id}"
env = "${var.env}"
service_code = "${var.service_code}"
target_subnets = module.wink_vpc.protected_subnet_ids
is_production = true
depends_on = [module.wink_vpc]
}
I'm stuck this issue for one day.
I needs Terraform Guru's help.
Please give me your great advice.
Thank you so much in advance.
Cheers!
Your production module has a count meta attribute. To reference the module you have to use an index, like:
value = module.production[0].eip_ids
I'm working on a React/Node.js app and I'm trying to read my IAM User credentials from ~/.aws/credentials file. I am trying to use fromIni from the #aws-sdk/credential-providers node package. According to the AWS SDK v3 documentation, I can do the following:
import { fromIni } from "#aws-sdk/credential-providers"; // ES6 import
// const { fromIni } = require("#aws-sdk/credential-providers"); // CommonJS import
const client = new FooClient({
credentials: fromIni({
// Optional. The configuration profile to use. If not specified, the provider will use the value
// in the `AWS_PROFILE` environment variable or a default of `default`.
profile: "profile",
// Optional. The path to the shared credentials file. If not specified, the provider will use
// the value in the `AWS_SHARED_CREDENTIALS_FILE` environment variable or a default of
// `~/.aws/credentials`.
filepath: "~/.aws/credentials",
// Optional. The path to the shared config file. If not specified, the provider will use the
// value in the `AWS_CONFIG_FILE` environment variable or a default of `~/.aws/config`.
configFilepath: "~/.aws/config",
// Optional. A function that returns a a promise fulfilled with an MFA token code for the
// provided MFA Serial code. If a profile requires an MFA code and `mfaCodeProvider` is not a
// valid function, the credential provider promise will be rejected.
mfaCodeProvider: async (mfaSerial) => {
return "token";
},
// Optional. Custom STS client configurations overriding the default ones.
clientConfig: { region },
}),
});
But when I try this in my index.js file:
import { fromIni } from '#aws-sdk/credential-providers';
const createLink = {
url: config.aws_appsync_graphqlEndpoint,
region: config.aws_appsync_region,
auth: {
type: config.aws_appsync_authenticationType,
credentials: fromIni()
}
};
and then run npm start, I get the following error:
export 'fromIni' (imported as 'fromIni') was not found in '#aws-sdk/credential-providers' (possible exports: fromCognitoIdentity, fromCognitoIdentityPool, fromTemporaryCredentials, fromWebToken)
It seems like the function I want isn't exported from the package but the documentation says otherwise.
Edit:
The output to #aws-sdk/credential-providers #aws-sdk/credential-provider-ini
port-dashboard#0.1.0 C:\Users\kshang\Documents\pov-ui
├─┬ #aws-sdk/client-cognito-identity-provider#3.79.0
│ ├─┬ #aws-sdk/client-sts#3.79.0
│ │ └─┬ #aws-sdk/credential-provider-node#3.79.0
│ │ └── #aws-sdk/credential-provider-ini#3.79.0
│ └─┬ #aws-sdk/credential-provider-node#3.79.0
│ └── #aws-sdk/credential-provider-ini#3.79.0
├─┬ #aws-sdk/credential-providers#3.79.0
│ ├─┬ #aws-sdk/client-cognito-identity#3.79.0
│ │ └─┬ #aws-sdk/credential-provider-node#3.79.0
│ │ └── #aws-sdk/credential-provider-ini#3.79.0 deduped
│ └── #aws-sdk/credential-provider-ini#3.79.0
└─┬ aws-amplify#4.3.20
├─┬ #aws-amplify/analytics#5.2.5
│ └─┬ #aws-sdk/client-firehose#3.6.1
│ └─┬ #aws-sdk/credential-provider-node#3.6.1
│ ├── #aws-sdk/credential-provider-ini#3.6.1
│ └─┬ #aws-sdk/credential-provider-process#3.6.1
│ └── #aws-sdk/credential-provider-ini#3.6.1 deduped
└─┬ #aws-amplify/geo#1.3.1
└─┬ #aws-sdk/client-location#3.48.0
└─┬ #aws-sdk/credential-provider-node#3.48.0
└── #aws-sdk/credential-provider-ini#3.48.0
Update: After doing more research and talking to some AWS Experts, it turns out we'll need to use Amazon Cognito in order to get credentials for our Browser based app.
I get the same error trying to use fromIni() for a simple CreateInvalidationCommand using the CloudFrontClient.
Trying to configure the client without the credentials key results in a Error: Credential is missing
My current workaround for developing locally is using a .env.local file, and using the accessKeyId and secretAccessKey properties for my config:
const cloudfront = new CloudFrontClient({
credentials: {
accessKeyId: process.env.REACT_APP_AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.REACT_APP_SECRET_ACCESS_KEY,
},
region: "us-east-1",
});
Which is obviously not ideal, but it works locally for testing and development.
I also wanted to note that fromEnv() is also missing from the exports. Which causes issues with this workaround in EC2 instances.
Either way, hoping to see this resolved in an update soon.
cache-invalidator#0.1.0 /Users/miguelmaldonado/Desktop/projects/prototypes/cache-invalidator
├─┬ #aws-sdk/client-cloudfront#3.85.0
│ └─┬ #aws-sdk/credential-provider-node#3.85.0
│ └── #aws-sdk/credential-provider-ini#3.85.0 deduped
└─┬ #aws-sdk/credential-providers#3.85.0
└── #aws-sdk/credential-provider-ini#3.85.0
I'm having an issue that I cannot explain.
I have a global constructor that sets TP:
void init_threads()
{
register long tp asm("tp");
asm volatile("mv %0, %1" : "=r"(tp) : "r"(&main_thread));
asm volatile("ret");
}
_ZN11microthread12init_threadsEv():
27e8c: 000d27b7 lui a5,0xd2
27e90: ba878793 addi a5,a5,-1112 # d1ba8 <_ZN11microthreadL11main_threadE>
27e94: 00078213 mv tp,a5
27e98: 00008067 ret
It's probably not the best way to do it, so feel free to suggest an improvement.
Unfortunately, it breaks my program, as register a5 is being used directly after this constructor call. I'm not sure how to change a5 to something else because it keeps picking it again and again. Not to mention, why does this happen? If I remove the naked attribute it still won't restore the value. Should it?
The init array loop looks like this:
│ 0x807e8 <__libc_init_array+68> jalr a5 │
│ 0x807ec <__libc_init_array+72> bne s2,s1,0x807dc <__libc_init_array+56> │
│ 0x807f0 <__libc_init_array+76> lui s0,0xc0 │
│ 0x807f4 <__libc_init_array+80> lui s2,0xc0 │
│ 0x807f8 <__libc_init_array+84> addi a5,s0,896 │
│ 0x807fc <__libc_init_array+88> addi s2,s2,952 │
│ 0x80800 <__libc_init_array+92> sub s2,s2,a5 │
│ 0x80804 <__libc_init_array+96> srai s2,s2,0x3 │
│ 0x80808 <__libc_init_array+100> beqz s2,0x80828 <__libc_init_array+132> │
│ 0x8080c <__libc_init_array+104> addi s0,s0,896 │
│ 0x80810 <__libc_init_array+108> li s1,0 │
│ 0x80814 <__libc_init_array+112> ld a5,0(s0) │
│ 0x80818 <__libc_init_array+116> addi s1,s1,1 │
│ 0x8081c <__libc_init_array+120> addi s0,s0,8 │
│ >0x80820 <__libc_init_array+124> jalr a5 │
The first jump to a5 is init_threads, while the second is whatever constructor comes next. Expectedly, a5 has a bogus value after returning from init_threads.
Thanks!
__attribute__((constructor, used))
static void init_threads()
{
microthread_set_tp(&main_thread);
}
asm(".section .text\n"
".global microthread_set_tp\n"
".type microthread_set_tp, #function\n"
"microthread_set_tp:\n"
" mv tp, a0\n"
" ret\n");
I'm posting this to show how I solved it, but to also make people aware of another issue I had: The function would not appear no matter how hard I tried, and the problem turned out to be that the current section was not .text. After making sure the correct section is selected, everything worked as expected. I believe you can have some pretty random issues if you forget to set the section!
Setting the baseUrl property to src in the .tsconfig has allowed me to import modules relative to the baseUrl like this:
import { ArrowRightIcon } from 'Shared/icons/navigation'
instead of :
import { ArrowRightIcon } from '../../../Shared/icons/navigation'
Question
How can I efficiently transform the thousands of such relative imports into absolute imports in my application since Find All functionality of any IDE does not understand the context?
Currently, I have to replace all the occurrences of ../../../Shared/, ../../../../Shared/, so on... with Shared/ and for all the directories in src. Even if I do that with help of regex, it won't help in the cases like example no. 2 below.
Other examples:
import { getActiveTabIdx } from 'Shared/utils/shared.helpers'
instead of import { getActiveTabIdx } from '../../../../../../../Shared/utils/shared.helpers'
import { TabWithLink } from 'Shared/components/Header'
instead of import { TabWithLink } from '../../components/Header'
import { layoutReducer } from 'Layout/state/layout.reducer'
instead of import { layoutReducer } from '../../Layout/state/layout.reducer'
My directory structure is:
.
├── src
│ ├── Shared
│ │ ├── components
│ │ ...
│ ├── Notification
│ │ ├── components
│ │ ...
│ ├── Planning
│ │ ├── components
│ │ ...
│ ├── Behaviour
│ │ ├── components
│ │ ...
│ └── Layout
│ │ ├── components
│ │ ├── state
│ ...
...
Currently installed version:
typescript: 4.2.4
vscode: 1.57.1
I have develop a django apps, and i start the server by using python manage.py runserver. without stop the server and without edit any code I wish it reload the server after 24 hoursy, any ideas on this?
You can use Cron for this.
From Wikipedia:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │ 7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * command to execute
Does it automatically reload when you edit one of its source files, like it does on Linux?
In that case, arrange for something to execute periodically, that "edits" a source file. Almost certainly, open for write and close is sufficient. On linux, touch file.py causes a restart. As a last resort create a Python file that is imported by your project, containing a function that you don't actually use. To restart, replace it with a copy of itself.