How to generate jhipster application into a different directory? - node.js

When I run the following in jhipster-generator's /cli directory:
cd cli
node jhipster.js
I'm generating the application in the same directory (cli). How would I change this directory to somewhere else? For example, export all the generated files into a specific directory.
I believe the directory has something to do with this line of code in jhipster.js:
const localCLI = require.resolve(path.join(process.cwd(), 'node_modules', 'generator-jhipster', 'cli', 'cli.js'));
Note: I'm not running the application with "jhipster" command.

Related

Pulumi file archive - no such file or directory

I feel like I'm making a silly mistake here, but Pulumi cannot seem to see the file I'm using to [create an asset][1] with. The files are right beside each other in the directory. Here is the file structure:
-- /resources
-- function.js
-- lambda.ts
Pretty simple. Here is the file where we try and use the Javascript file as an asset for the Lambda we are creating:
// lambda.ts
import * as pulumi from '#pulumi/pulumi';
import * as aws from '#pulumi/aws';
const file = new pulumi.asset.FileAsset('./function.js');
console.log('file', file);
export const exampleFunction = new aws.lambda.Function('exampleFunction', {
role: role.arn,
runtime: 'nodejs14.x',
code: file,
});
I've written a script to run my Pulumi commands. I also pwd and ls the file directory to confirm that the file is there.
# deploy.sh
#!/bin/sh
ls resources
pulumi preview
Output/error:
ls resources -- function.js lambda.ts
pulumi preview --
Error: failed to register new resource exampleFunction [aws:lambda/function:Function]: 2 UNKNOWN: failed to compute archive hash: couldn't read archive path './function.js': stat ./function.js: no such file or directory
Kinda lost on this one. The file is right there.
Edit:
I've realized that the file path must be relative to where the Pulumi.yaml file is located, so one directory above /resources in this case.
Where is deploy.sh or more specifically, pulumi preview being run?
Is it being run in the "resources" folder, or someplace else - e.g. in the folder above?
If it's not being run from the resources folder, then that's likely the issue and so you need to provide the path to function.js from where pulumi is being run.
You should be using FileAsset and not FileArchive, as FileArchive is for tar.gz and related archive files: https://www.pulumi.com/docs/intro/concepts/assets-archives/
At least I think that's what's going on. If that's true then the error message is not great as it doesn't tell you what the actual problem is.

AWS Elastic beanstalk - My deployed app can't seem to write pdf's into this directory i've set up in my project folder

I am currently using nodejs that is deployed in ebs on aws. I have a function that will write a pdf and then email it off but it says the file path can't be found. I've verified the project file seems to be /var/app/current/, but changing the reference of the file path doesn't seem to remove the error. Any idea how to go about fixing this?
The /var/app/current/ does not exist initially. Its only created at the very last stage of your deployment.
The deployment happens in /var/app/staging/ folder, and at the very last, once everything finishes, /var/app/staging/ is moved into /var/app/current/.
Thus, I would not recommend using absolute paths in your project or config files. Its better to use relative path or container_commands for config scripts:
The specified commands run as the root user, and are processed in alphabetical order by name. Container commands are run from the staging directory, where your source code is extracted prior to being deployed to the application server.

How do I set home folder in Heroku system variable?

I'm deploying a node.js app on Heroku dyno and using config module that requires me to define a system variable NODE_CONFIG_DIR with the location of the config folder.
The config folder is located on my project's root.
I tried to define the system variable NODE_CONFIG_DIR using the following values, all failed:
./config
~/config
app/config
~/app/config
./app/config
$HOME/config
$HOME/app/config
I keep getting this error:
WARNING: No configurations found in configuration directory:app/config
(replace app/config with any of the values above)
I manage to set a system variable, but its value is not pointing the right place.
What is the correct way to refer to the root of my tree when using a system variable in Heroku?
Based on documentation - if config folder is in the root of your application you should not need to specify $NODE_CONFIG_DIR env variable.
From node-config documentation:
Node-config reads configuration files in the './config' directory for the running process, typically the application root. This can be overridden by setting the $NODE_CONFIG_DIR environment variable to the directory containing your configuration files. It can also be set from node, before loading Node-config:
process.env["NODE_CONFIG_DIR"] = __dirname + "/configDir/";
const config = require("config");
$NODE_CONFIG_DIR can be a full path from your root directory, or a relative path from the process if the value begins with ./ or ../.
You could use above code to set it from your node code.
You were close: /app is the correct path. You can verify it by running heroku run bash.
It was my bad...
Both answers are correct but didn't solve my issue.
The problem was that I used lowercase for my configuration file name while the NODE_ENV value was uppercase.

Run NodeJS application without environment variable

I have a node application that I run on a Linux Server (CentOS 6.5) by setting my environment with a bash script
env_nodejs.sh
#!/bin/bash
PATH=$PATH:/opt/nodejs/node-v6.9.4-linux-x64/bin
export PATH
So that I can
# . ./env_nodejs.sh
# node /var/www/html/application/app.js
That all works fine but if I do the following in a separate script
run_app.sh
#!/bin/bash
$COMMAND=/opt/nodejs/node-v6.9.4-linux-x64/bin/node
$SITE=/var/www/html/application/app.js
nohup $COMMAND $SITE > /tmp/nodeapp.log &
This runs the node server and app but with errors that seem to be related to npm
Error: Failed to lookup view "control/users" in views directory "/views"
I have a feeling this is because the environment is not set but is there a way to run it correctly without the environment or to pass additional parameters for the npm location?
It seems like it's trying to find the files in "/views" which is a top level directory in your file system.
If that is the case then it's not PATH but PWD that's in fault here.
Make sure that when you define where to look for the views in your app, instead of saying 'views' or './views' you use path.join(__dirname, 'views') instead.
You first need to require path with: var path = require(path);
Of course this is just my guess as you didn't include any part of your source code that you have problem with.

Is that the 'path to war' which I am giving wrong? If yes,how do I do a rollback?

I have been trying to use the command to rollback the last process of deploying the website which was interrupted due to a network failure.
The generic command that I am using while inside the bin directory of server's SDK (On Linux) is :
./appcfg.sh rollback /path_to_the_war_directory_that_has_appengine-web.xml
Is this the way we do a rollback ? If not please tell me the method.
_(I was asked to make a directory war in the project directory and place the WEB-INF folder in that with appengine-web.xml inside it. It may be wrong)_
I am fully convinced that I am making a mistake while giving the path to my app .
Shot where my .war file is there :
Now the command that I am using is (while inside the bin directory of the server's SDK) :
./appcfg.sh rollback /home/non-admin/NetbeansProjects/'Personal Site'/web/war
The following is the representation of the path to war directory :
Where am I wrong ? How should I run this command so that I am able to deploy my project once again ?
On running the above command I get this message :
Unable to find the webapp directory /home/non-admin/NetbeansProjects/Personal Site/web/war
usage: AppCfg [options] <action> [<app-dir>] [<argument>]
NOTE : I have duplicated the folder WEB-INF. There is still a folder named WEB-INF inside the web directory that contains all other xml files.
The error tells you that the folder /home/non-admin/NetbeansProjects/Personal Site/web/war does not exist. If you look carefully the name of the folder is NetBeansProjects (the filesystem in Linux is case-sensitive).
So, you should run instead the command:
./appcfg.sh rollback /home/non-admin/NetBeansProjects/'Personal Site'/web/war
and just to make sure that the directory exists run first
ls /home/non-admin/NetBeansProjects/'Personal Site'/web/war

Resources