Name: bc-quick-start-guide
Owner: LINE
Description: null
Created: 2016-03-10 05:42:32.0
Updated: 2016-10-31 05:35:34.0
Pushed: 2016-03-14 04:41:42.0
Homepage: null
Size: 33
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This tutorial will have you deploying a Java BusinessConnect server in minutes.
Hang on for a few more minutes to learn how it all works, so you can make the most out of LINE platform.
The tutorial assumes that you have:
The code provided in this repository is intended to be used as examples only and is not recommended for production use.
In this step you will install the Heroku Toolbelt. This provides you access to the Heroku Command Line Interface (CLI),
which can be used for managing and scaling your applications and add-ons. A key part of the toolbelt is the heroku
local
command, which can help in running your applications locally.
Once installed, you can use the heroku
command from your command shell.
Log in using the email address and password you used when creating your Heroku account:
roku login
r your Heroku credentials.
l: java@linecorp.com
word:
Authenticating is required to allow both the heroku and git commands to operate.
In this step, you will prepare a simple BusinessConnect application that can be deployed.
Execute the following commands to clone the sample application:
t clone https://github.com/line/bc-quick-start-guide.git
bc-quick-start-guide
You now have a functioning git repository that contains a simple application as well as a pom.xml
file, which is used
by Java?s dependency manager, Maven.
In this step you will deploy the BusinessConnect application to Heroku.
Create an application on Heroku, which prepares Heroku to receive your source code:
roku create
ting guarded-atoll-4857... done, stack is cedar-14
s://guarded-atoll-4857.herokuapp.com/ | https://git.heroku.com/guarded-atoll-4857.git
remote heroku added
When you create an application, a git remote (called heroku
) is also created and associated with your local git
repository.
Heroku generates a random name (in this case guarded-atoll-4857
) for your application, or you can pass a parameter to
specify your own application name.
Now deploy your code:
t push heroku master
ting objects: 108, done.
a compression using up to 8 threads.
ressing objects: 100% (37/37), done.
ing objects: 100% (108/108), 19.72 KiB | 0 bytes/s, done.
l 108 (delta 48), reused 105 (delta 48)
te: Compressing source files... done.
te: Building source:
te:
te: -----> Java app detected
te: -----> Installing OpenJDK 1.8... done
te: -----> Installing Maven 3.3.3... done
te: -----> Executing: mvn -B -DskipTests clean dependency:list install
te: [INFO] Scanning for projects...
(detail messages skipped) ...
te: [INFO] ------------------------------------------------------------------------
te: [INFO] BUILD SUCCESS
te: [INFO] ------------------------------------------------------------------------
te: [INFO] Total time: 15.134 s
te: [INFO] Finished at: 2015-11-08T10:27:03+00:00
te: [INFO] Final Memory: 28M/230M
te: [INFO] ------------------------------------------------------------------------
te: -----> Discovering process types
te: Procfile declares types -> web
te:
te: -----> Compressing... done, 65.0MB
te: -----> Launching... done, v5
te: https://guarded-atoll-4857.herokuapp.com/ deployed to Heroku
te:
te: Verifying deploy.... done.
ttps://git.heroku.com/guarded-atoll-4857.git
new branch] master -> master
The BusinessConnect application is now deployed. Ensure that at least one instance of the app is running:
roku ps:scale web=1
It is not a good idea to put your channel information such as channel secret into git. You may define the confidential
information as heroku environment variables and store these variables into a .env
file for future usage.
Add the heroku gem plugin:
roku plugins:install git://github.com/ddollar/heroku-config.git
alling git://github.com/ddollar/heroku-config.git... done
There should be a line .env
in file .gitignore
to prohibit .env
file being uploaded to git.
Now you can set your channel secret and channel access token:
roku config:set CHANNEL_SECRET=<your channel secret>
ing config vars and restarting guarded-atoll-4857... done
roku config:set CHANNEL_ACCESS_TOKEN=<your channel access token>
ing config vars and restarting guarded-atoll-4857... done
Store these setting into .env
file:
roku config:pull
ig for guarded-atoll-4857 written to .env
You may execute heroku config:push
to restore these setting to your heroku host.
roku config:push
ig in .env written to guarded-atoll-4857
More information about heroku configuration please refer to heroku-config.
Heroku treats logs as streams of time-ordered events aggregated from the output streams of all your application and Heroku components, providing a single channel for all of the events.
View information about your running app using one of the logging commands,
heroku logs
:
roku logs --tail
-07-06T08:44:45.008841+00:00 heroku[web.1]: Starting process with command `java -cp target/classes:target/dependency/* Main`
-07-06T08:44:47.941949+00:00 app[web.1]: [Thread-0] INFO spark.webserver.SparkServer - == Spark has ignited ...
-07-06T08:44:47.949901+00:00 app[web.1]: [Thread-0] INFO org.eclipse.jetty.server.Server - jetty-9.0.2.v20130417
-07-06T08:44:47.946093+00:00 app[web.1]: [Thread-0] INFO spark.webserver.SparkServer - >> Listening on 0.0.0.0:6243
-07-06T08:44:48.280107+00:00 app[web.1]: [Thread-0] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@42d76c7c{HTTP/1.1}{0.0.0.0:6243}
-07-06T08:44:48.703339+00:00 heroku[web.1]: State changed from starting to up
Visit your application by curl
command, and you?ll see another log message generated (Please ignore the error message
in the response content of curl
). Press Control+C
to stop streaming the logs.
rl -v https://guarded-atoll-4857.herokuapp.com/events -d "Any test string"