Run app locally with Heroku - StanfordBioinformatics/pulsar_lims GitHub Wiki
You can deploy Pulsar locally for testing purposes, but first make sure you already have PostgreSQL installed. You also need to create the Postgres database for the development environment. Open up config/database.yml. Find the block that says "development" and then take note of the value of the "database" property. You'll need to create a Postgres database locally that has the same name. You can do this using createdb
, which comes prepackaged with PostgreSQL.
You'll need to use git to clone Pulsar locally as described on the deployment page.
Heroku CLI has a command heroku local
that allows you to start an app locally. This command should be run in the root folder of the app, as it expects a .env file in the app's root directory that stores key=value environment variable settings. You'll need to add to this file the key=value settings for the environment variables that were discussed on the deployment page. Regarding the APP_HOST_NAME
environment variable, you'll need to set that to localhost:5000
since you are using Pulsar locally. The 5000 port is where the Puma Web server is running.
You don't have to use heroku local
, you can instead just use the rails server
command (or rails s
for short). I still recommend creating a .env file though in order to store your environment variables. This way, you can just source that file prior to starting the server. Thus, your sequence of commands would be
source .env
rails s
It's best if you go ahead and set up an S3 bucket as mentioned on the deployment page, so that you can set the relevant AWS environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and S3_BUCKET) in the .env
file. You can omit this step if you don't plan on uploading any files when you test locally. It's worth noting here that there are some form fields that upload files directly to the database (i.e. protocols that can be reused across different objects), and you'll be just fine in this case. But other form fields upload image files and other one-off files to a specified AWS bucket. In this latter case, you'll run into trouble when skipping these environment variables, and see an error that reads:
undefined method `presigned_post' for nil:NilClass
Heroku uses Mailgun - a Heroku addon that incurs additional charges - to send email containing a confirmation link to new users upon signing up. If you are only using Pulsar to test it out locally, then you don't need to add Mailgun. Hence, you can omit from the .env file the MAILGUN* environment variables that were discussed on the deployment page. If you do that though, you'll have to look in the log file for the confirmation code. The log file is located in the app root at logs/development.log
. Pulsar still logs the message that it would have sent out had email been configured, so you can parse the confirmation code out of there. For example, you would see something like this in the log file for a new user named bob:
...
Sent mail to [email protected] (25.7ms)
Date: Sun, 17 Dec 2017 00:05:34 -0800
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: New Account on Pulsar
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Welcome [email protected]!</p>
<p>You can confirm your account email through the link below:</p>
<p><a href="http://localhost/users/confirmation?confirmation_token=nUT5Soc8eMwkz9tthxi7">Confirm my account</a></p>
<p>Once your account is active, you'll have viewer status by default.<br>
If you need access to create and edit objects, please email support at [email protected]<br>
</p>
...
You can copy the link out of this and enter it into your browser to satisfy the confirmation, thereby activating the user's account. Alternatively, you can do this directly on the command-line in the RAILS console by just setting the time of the confirmation via the User.confirmed_at
attribute, i.e.:
encyclia:users nathankw$ rails c
Loading development environment (Rails 4.2.8)
pry(main)> u = User.last
pry(main)> u.confirmed_at = Time.now()
pry(main)> u.save
See the corresponding section on the deployment page.
Direct your browser to http://localhost:5000.