-
Notifications
You must be signed in to change notification settings - Fork 14
/
README.txt
142 lines (78 loc) · 4.39 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Wing is a modern web services platform written in Perl. It allows you to define objects and then automatically generates database schemas, restful web services, and even web form handlers to manage those objects. It's got built in users, sessions, single-sign-on and more.
INSTALLATION
0. Do the prep for your OS. For example, if you're on Amazon Linux, then look at README.Amazon.txt to see the prep steps.
1. Clone this repository into /data/Wing on your machine:
mkdir /data
cd /data
git clone https://github.com/plainblack/Wing.git
2. Install the prereqs.
/data/Wing/bin/setup/setup.sh
3. Verify/set apps paths.
perl -v # should return 5.26.2, the version required by Wing. If not:
source /data/Wing/bin/dataapps.sh
perl -v # should return 5.26.2
4. Create a project in /data/MyApp:
cd /data/Wing/bin
export WING_HOME=/data/Wing
perl wing_init_app.pl --app=MyApp
NOTE: If you get an error a la "Illegal division by zero" from warnings.pm in this step, revisit step 3.
5. Create a database on your MySQL server to host the project, and edit the Wing config to match:
NOTE: It is important that your my.cnf file for MySQL contain the following lines in the [mysqld] section. If not, add them and restart it:
collation_server=utf8_unicode_ci
character_set_server=utf8
mysql -uroot -p -e "create database my_project"
mysql -uroot -p -e "grant all privileges on my_project.* to some_user@localhost identified by 'some_pass'"
mysql -uroot -p -e "flush privileges"
6. Modify the config file. You need to at least edit the "db" section to tell Wing how to log in to your database. You may also wish to update other settings.
vi /data/MyApp/etc/wing.conf
mkdir /data/apps/logs
chown nobody /data/apps/logs
NOTE: You can also edit the location of the logs in /data/MyApp/etc/log4perl.conf. It is defaultly set to /data/apps/logs/wing.log
7. Initialize the database:
cd /data/MyApp/bin
export WING_HOME=/data/Wing
export WING_APP=/data/MyApp/
export WING_CONFIG=/data/MyApp/etc/wing.conf
wing db --prepare_install
wing db --install --force
8. Start up the rest server and/or web server:
wing rest --start
wing web --start
9. Now you can connect to the rest server and see if it's alive:
curl http://localhost:5000/api/status
curl http://localhost:5001/account
NOTE: By default there is one user named 'Admin' with a password of '123qwe'.
10. We also provide you with an nginx config file to give you a baseline for serving your apps. You can start it like this:
nginx -c /data/MyApp/etc/nginx.conf
NOTE: This is required to merge together the two services, as well as serve up static files.
WARNING: There is no "home" page. Wing is expecting you to create it. After you start Nginx you'll be able to access /account and /admin. Everything is will 404.
OPTIONAL
11. Wing has a job server called Wingman, which is backed by beanstalkd. To run it you simply install beanstalkd, which you can download from here: http://kr.github.io/beanstalkd/
Then you can run it like so:
beanstalkd &
And finally you run Wing's job server by typing:
wing wingman --start
ADDING FUNCTIONALITY
We also provide you with tools to build out your app. For example, if you want to add a new class to your app, you can:
wing class --add=NewObject
This will dynamically generate a NewObject.pm class file for you in /data/MyApp/lib/MyApp/DB/Result/, and create a Rest
interface at /data/MyApp/lib/MyApp/Rest/NewObject.pm, and create a Web interface at /data/MyApp/lib/MyApp/Web/NewObject.pm.
It will even add the lines needed in /data/MyApp/lib/MyQpp/Rest.pm and /data/MyApp/lib/MyApp/Web.pm.
After adding a new class you'll need to restart a few services:
cd /data/MyApp/bin
./restart_web.sh
./restart_rest.sh
wingman.pl restart
To upgrade your database with the schema changes for your new class:
increment the database version number in MyApp::DB
wing db --prepare
wing db --upgrade
For more information on managing the database schema see the DBIx::Class::DeploymentHandler documentation.
Once you've built out your object and you're ready to generate some web templates for it you can do:
wing class --template=NewObject
That will add templates in /data/MyApp/views/newobject/*.tt.
We can even generate some basic tests for you:
wing class --test=NewObject
That will add tests in /data/MyApp/t
For more information type:
perldoc lib/Wing/FirstApp.pod